Thread grosse hashes optimieren: 800-900 keys (19 answers)
Opened by lichtkind at 2006-06-21 22:38

Taulmarill
 2006-06-22 18:17
#67525 #67525
User since
2004-02-19
1750 Artikel
BenutzerIn

user image
also ich kann kaum einen unterschied zwischen einem hash mit 26 und einem mit 676 keys feststellen.
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use strict;
use warnings;
use Benchmark qw/cmpthese/;

sub hashmap { my $cnt = 1; map { $_, $cnt++ } @_; }

my @sml_list = ( 'a'..'z' );
my @big_list = map { my $char = $_; map { "$char$_" } 'a'..'z' } 'a'..'z';
my %sml_hash = hashmap( @sml_list );
my %big_hash = hashmap( @big_list );

cmpthese( -1, {
sml => sub { defined $sml_hash{ $sml_list[ rand @sml_list ] }; },
big => sub { defined $big_hash{ $big_list[ rand @big_list ] }; },
} );
$_=unpack"B*",~pack"H*",$_ and y&1|0& |#&&print"$_\n"for@.=qw BFA2F7C39139F45F78
0A28104594444504400 0A2F107D54447DE7800 0A2110453444450500 73CF1045138445F4800 0
F3EF2044E3D17DE 8A08A0451412411 F3CF207DF41C79E 820A20451412414 83E93C4513D17D2B

View full thread grosse hashes optimieren: 800-900 keys