use strict; use warnings; use Time::HiRes 'time'; use TokyoCabinet; use KyotoCabinet; my %hash; my $ob2 = tie my %h2, 'TokyoCabinet::ADB', '+'; # in-memory tree my $ob4 = tie my %h4, 'KyotoCabinet::DB', '%'; # in-memory tree my $start = time; # Plain hash 1911 MiB, 10.182 seconds # for ( 1 .. 10e6 ) { # $hash{$_} = "$_ some string..."; # } # Tokyo Cabinet 627 MiB, 10.165 seconds # for ( 1 .. 10e6 ) { # $ob2->STORE($_ => "$_ some string..."); # } # Kyoto Cabinet 453 MiB, 10.062 seconds for ( 1 .. 10e6 ) { $ob4->STORE($_ => "$_ some string..."); } printf {*STDERR} "capture memory consumption in top: %0.03f\n", time - $start; 1 for ( 1 .. 2e8 );