Thread Hashes (27 answers)
Opened by BrownWolf at 2003-08-15 22:03

Dubu
 2003-08-16 15:30
#53435 #53435
User since
2003-08-04
2145 Artikel
ModeratorIn + EditorIn

user image
Dann sag das meinem Perl:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark qw/cmpthese/;

my %hash;
my &#36key="foo";

cmpthese (-10, {
    ohne  => sub { &#36hash{&#36key}=0; &#36hash{&#36key}++ for 0 .. 1_000_000; },
    mit   => sub { &#36hash{"&#36key"}=0; &#36hash{"&#36key"}++ for 0 .. 1_000_000; },
});

Code: (dl )
1
2
3
4
5
6
Benchmark: running mit, ohne for at least 10 CPU seconds...
      mit: 11 wallclock secs (10.36 usr +  0.01 sys = 10.37 CPU) @  0.87/s (n=9)
     ohne: 11 wallclock secs (10.12 usr +  0.02 sys = 10.14 CPU) @  2.66/s (n=27)
    s/iter  mit ohne
mit    1.15   -- -67%
ohne  0.376 207%   --

View full thread Hashes