in reply to RE:(3) Hash of hashes question
in thread Hash of hashes question
I think it is the because sort() is very fast, and you are comparing it with an if/then (?:) control structure, which is inherantly slow.
Well, another thing to do besides benchmarking is profiling:
#!/usr/bin/perl use strict; use Devel::OpProf qw(profile print_stats zero_stats ); profile(1); # turn on profiling my $now = 8; # we'll pretend it's between 8 and 9 PM my %url = ( monday => { @{[map(($_,1), (1..1000))]} } ); #start profiling zero_stats; $now = (sort grep {$_ <= $now} keys %{$url{'monday'}})[-1]; print_stats; zero_stats; $now = ($now < $_ && $_ < 8 ? $_ : $now) for keys %{$url{'monday'}}; print_stats;
Well, this tells us a lot!
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
So we see that just the control loop by iself takes almost as much "action" as the whole first algorithm
Paris Sinclair | 4a75737420416e6f74686572 pariss@efn.org | 205065726c204861636b6572 I wear my Geek Code on my finger.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE:(5) Hash of hashes question
by Russ (Deacon) on Jun 19, 2000 at 23:10 UTC | |
by Aighearach (Initiate) on Jun 20, 2000 at 04:00 UTC | |
by Russ (Deacon) on Jun 20, 2000 at 05:28 UTC | |
by Aighearach (Initiate) on Jun 20, 2000 at 05:45 UTC |