lhp@nereida:~/Lperl/src$ cat -n benchtypeglobs3.pl 1 #!/usr/bin/perl 2 use strict; 3 use Benchmark; 4 5 our ($i, $r, $b, $s); 6 7 local $i; 8 *b = *i; 9 $r = \$i; 10 $s = "i"; 11 12 no strict 'refs'; 13 timethese(4, 14 { reference => sub { for ($$r = 0; $$r < 1e6; $$r++) { $$r; } }, 15 typeglob => sub { for ($b = 0; $b < 1e6; $b++) { $b; } }, 16 symbolic => sub { for ($$s = 0; $$s < 1e6; $$s++) { $$s; } }, 17 });El resultado de la ejecución en
nereida
nos da la siguiente relación:
lhp@nereida:~/Lperl/src$ benchtypeglobs3.pl Benchmark: timing 4 iterations of reference, symbolic, typeglob... reference: 1 wallclock secs ( 1.13 usr + 0.00 sys = 1.13 CPU) @ 3.54/s (n=4) symbolic: 6 wallclock secs ( 6.33 usr + 0.00 sys = 6.33 CPU) @ 0.63/s (n=4) typeglob: 1 wallclock secs ( 0.75 usr + 0.00 sys = 0.75 CPU) @ 5.33/s (n=4)
Casiano Rodríguez León