use Time::HiRes qw(time); use Inline C => <<'EOC'; int foo(int x) {return x + 1;} int foo_bar(int x) { int i; for(i = 0; i < x; i++){ foo(i); } return x + i; } EOC $iterations = 10000000; # 1e7 $t = time; foo($_) for 1 .. $iterations; print "# ", time - $t, "\n"; $t = time; foo_bar($iterations); print "# ", time - $t, "\n"; # Outputs (on Windows): # 1.57560181617737 # 0.0026400089263916