in reply to code execution speed and variable name length
Read (and heed) what the others above said about premature optimization. But here's what I get for one pathalogical exaple using large hash keys.
-- All code is 100% tested and functional unless otherwise noted.
greg@sparky:~/perl$ cat hashing_short #!/usr/bin/perl my $short="a"; my $long="This is a long hash key"x1000; my %h; $h{$short}++ for (1..1000000); greg@sparky:~/perl$ time hashing_short real 0m0.376s user 0m0.375s sys 0m0.001s greg@sparky:~/perl$ cat hashing_long #!/usr/bin/perl my $short="a"; my $long="This is a long hash key"x1000; my %h; $h{$long}++ for (1..1000000); greg@sparky:~/perl$ time hashing_long real 2m46.893s user 2m38.196s sys 0m0.278s
-- All code is 100% tested and functional unless otherwise noted.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Pathological example
by hv (Prior) on Jul 30, 2004 at 12:33 UTC |
In Section
Seekers of Perl Wisdom