From e5f476d0fa9eb665fe43c7c316bf079e9c3b929f Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Wed, 29 Dec 2004 20:11:34 +0000 Subject: [PATCH] benchmark hash creation for various implementations git-svn-id: file:///home/dpavlin/svn/Biblio-Isis/trunk@14 4670fa4d-42ec-0310-ab5b-a66af6943492 --- Makefile.PL | 3 +++ scripts/bench.pl | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Makefile.PL b/Makefile.PL index aea7200..b1f2135 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -36,5 +36,8 @@ cmp: time ./scripts/dump_isis.pl > isis.txt time ./scripts/dump_openisis.pl > openisis.txt +bench: all + cd ./scripts/ && ./bench.pl + MAKE_MORE } diff --git a/scripts/bench.pl b/scripts/bench.pl index e7e130b..ae79854 100755 --- a/scripts/bench.pl +++ b/scripts/bench.pl @@ -16,6 +16,15 @@ my $isis = IsisDB->new ( debug => shift @ARGV, ); +my $isis_filter = IsisDB->new ( + isisdb => $isisdb, + debug => shift @ARGV, + hash_filter => sub { + my $v = shift; + return lc($v); + } +); + my $rows = $isis->{'maxmfn'}; my $db = OpenIsis::open( $isisdb ); @@ -28,9 +37,28 @@ my $r = timethese( -5, { IsisDB => sub { $isis->fetch( $mfn++ % $rows + 1 ); }, + IsisDB_hash => sub { + $isis->to_hash( $mfn++ % $rows + 1 ); + }, + IsisDB_hash_filter => sub { + $isis_filter->to_hash( $mfn++ % $rows + 1 ); + }, + OpenIsis => sub { OpenIsis::read( $db, $mfn++ % $rows + 1 ); }, + + OpenIsis_hash => sub { + my $row = OpenIsis::read( $db, $mfn++ % $rows + 1 ); + my $rec; + no strict 'refs'; + foreach my $f (keys %{$row}) { + foreach my $v (@{$row->{$f}}) { + push @{$rec->{$f}}, OpenIsis::subfields($v); + } + } + + }, } ); cmpthese $r; -- 2.20.1