in reply to $r-dir_config and speed
Never one to wait for an answer, I kept digging and finally decided to pull out the trusty Benchmark module:
#!/usr/bin/perl -w use strict; use Benchmark; my %hash = ( DefaultLimit => 900, TimeLimit => 900, MODE => 'Off' ); sub by_hash { my $time_to_die; if ($hash{'TimeLimit'}) { if ($hash{'TimeLimit'} < $hash{'DefaultLimit'}) { $time_to_die = $hash{'TimeLimit'}; } else { $time_to_die = $hash{'DefaultLimit'}; } } else { $time_to_die = $hash{'DefaultLimit'}; } } sub by_var { my ($default, $time_to_die, $limit); $default = $hash{'DefaultLimit'}; $limit = $hash{'TimeLimit'} if ($hash{'TimeLimit'}); ($limit && ($limit < $default)) ? $time_to_die = $limit : $tim +e_to_die = $default; } timethese (100000, { hash => 'by_hash', var => 'by_var'});
Yeilds this:
[13:20:12 jhorner@gateway lib]$ ./test1.pl Benchmark: timing 100000 iterations of hash, var... hash: 5 wallclock secs ( 4.57 usr + 0.00 sys = 4.57 CPU) @ 21 +881.84/s (n=100000) var: 4 wallclock secs ( 3.74 usr + 0.00 sys = 3.74 CPU) @ 26 +737.97/s (n=100000) [13:20:24 jhorner@gateway lib]$
This leads me to believe that I should use temp variables to store this data. Anyone have any comments, or suggestions?
Has anyone else reached any other results?
Thanks,
J. J. Horner Linux, Perl, Apache, Stronghold, Unix jhorner@knoxlug.org http://www.knoxlug.org/
|
|---|