83
|
1 #!/usr/bin/perl
|
93
|
2 use strict;
|
167
|
3 use Time::HiRes qw(gettimeofday tv_interval);
|
93
|
4
|
167
|
5 sub func {
|
194
|
6 1;
|
167
|
7 }
|
|
8
|
|
9 my $t0 = [gettimeofday()];
|
|
10
|
|
11 for(my $i = 0; $i < 1000000; $i++) {
|
194
|
12 func(1);
|
167
|
13 }
|
|
14
|
|
15 print tv_interval($t0),"\n";
|
|
16
|
|
17 my $fn = sub { 1; };
|
|
18
|
|
19 $t0 = [gettimeofday()];
|
|
20
|
|
21 for(my $i = 0; $i < 1000000; $i++) {
|
194
|
22 &$fn(1);
|
167
|
23 }
|
134
|
24
|
167
|
25 print tv_interval($t0),"\n";
|
|
26
|
|
27 sub dummy() { 0; }
|
|
28
|
|
29 $t0 = [gettimeofday()];
|
|
30
|
|
31 for(my $i = 0; $i < 1000000; $i++) {
|
194
|
32 dummy;
|
167
|
33 }
|
|
34
|
|
35 print tv_interval($t0),"\n";
|
|
36
|
|
37 $t0 = [gettimeofday()];
|
|
38
|
|
39 for(my $i = 0; $i < 1000000; $i++) {
|
194
|
40 1;
|
167
|
41 }
|
|
42
|
|
43 print tv_interval($t0),"\n";
|
|
44
|