in reply to Time Penalty vs. Global Symbols
#!perl use strict; use warnings; use Benchmark qw(:all); my $foo; timethese('50000000', { 'test_1' => sub { $foo = 1; }, 'test_2' => sub { my $bar = 1; }, }); 1; __END__ fred@fishman ~ $ perl scope.pl Benchmark: timing 10000000 iterations of test_1, test_2... test_1: 0 wallclock secs ( 1.03 usr + 0.01 sys = 1.04 CPU) @ 96 +15384.62/s (n=10000000) test_2: 2 wallclock secs ( 1.38 usr + 0.01 sys = 1.39 CPU) @ 71 +94244.60/s (n=10000000) fred@fishman ~ $ perl scope.pl Benchmark: timing 50000000 iterations of test_1, test_2... test_1: 6 wallclock secs ( 5.19 usr + 0.01 sys = 5.20 CPU) @ 96 +15384.62/s (n=50000000) test_2: 6 wallclock secs ( 6.51 usr + 0.00 sys = 6.51 CPU) @ 76 +80491.55/s (n=50000000)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Time Penalty vs. Global Symbols
by xdg (Monsignor) on Jan 13, 2005 at 21:33 UTC |