#!/usr/bin/perl # # Is a system call for hostname faster then the Sys::Hostname::hostname() call? use Benchmark qw( cmpthese timethese); use warnings; use strict; use Sys::Hostname; my $host; sub system_loop { $host = `hostname` } sub module_loop { $host = hostname(); } timethese (-30, { # number indicates seconds to run the test for (-5 is 5seconds) or total test runs to do (if number +) 'system method' => sub { system_loop() }, 'module method' => sub { module_loop() }, });