>From a5255321417e1d453908e1c17edbcc9c15109f65 Mon Sep 17 00:00:00 2001 From: Frank Dittrich Date: Sat, 23 Jun 2012 18:51:32 +0200 Subject: [PATCH] Several enhancements for relbench 1. If there are benchmarks that exist only in file 1 and benchmarks that exist only in file 2, point out the possibility to convert both benchmark files using benchmark-unify, so that more benchmarks might be compared 2. If a particular benchmark appears several times in the same file, print a message to STDERR, and pick the higher values for comparision (higher real value is considered here, only if the real values are the same, the higher virtual value is considered). 3. Add support for an optional verbose mode: ./relbench -v file1 file2 instead of ./relbench file1 file2 With verbose mode, for each benchmark that exists in both files, the ratio of real / virtual c/s rate is printed like this: Ratio: 0.95543 real, 0.96987 virtual generic crypt(3) DES:Only one salt Ratio: 1.00379 real, 1.00388 virtual HalfLM C/R DES:Many salts Ratio: 1.06590 real, 1.06586 virtual FreeBSD MD5:Raw Ratio: 2.92454 real, 1.47022 virtual Invision Power Board 2.x salted MD5:Only one salt Ratio: 0.97287 real, 0.97287 virtual dynamic_20: Cisco PIX (MD5 salted):Many salts This allows to use ./relbench -v file1 file2 |grep "^Ratio:"|cut -f 2-|sort -nr This way, the benchmarks with the best performance improvement and the benchmarks with the worst performance regression can easily be identified. --- run/relbench | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 46 insertions(+), 9 deletions(-) diff --git a/run/relbench b/run/relbench index 022d54c..e2f5ccf 100755 --- a/run/relbench +++ b/run/relbench @@ -26,6 +26,8 @@ # $warned = 0; +$onlyin1 = 0; +$onlyin2 = 0; sub parse { @@ -63,19 +65,33 @@ sub parse print STDERR "Could not parse: $_\n" if (!$ok); } -die "Usage: $0 BENCHMARK-FILE-1 BENCHMARK-FILE-2\n" if ($#ARGV != 1); +die "Usage: $0 [-v] BENCHMARK-FILE-1 BENCHMARK-FILE-2\n" if ($#ARGV != 1 && ($#ARGV != 2 || $ARGV[0] ne '-v')); -open(B1, '<' . $ARGV[0]) || die "Could not open file: $ARGV[0] ($!)"; -open(B2, '<' . $ARGV[1]) || die "Could not open file: $ARGV[1] ($!)"; +if ($#ARGV != 1) { + open(B1, '<' . $ARGV[1]) || die "Could not open file: $ARGV[1] ($!)"; + open(B2, '<' . $ARGV[2]) || die "Could not open file: $ARGV[2] ($!)"; + $verbose = 1; +} else { + open(B1, '<' . $ARGV[0]) || die "Could not open file: $ARGV[0] ($!)"; + open(B2, '<' . $ARGV[1]) || die "Could not open file: $ARGV[1] ($!)"; + $verbose = 0; +} $_ = ''; parse(); while () { parse(); next unless (defined($id)); - $b1r{$id} = $real; - $b1v{$id} = $virtual; -} + if(defined($b2r{$id})) { + print STDERR "More than one benchmark for $id in file 2\n"; + if($real > $b1r{$id} || ($real == $b1r{$id} && $virtual > $b1v{$id})) { + $b1r{$id} = $real; + $b1v{$id} = $virtual; + } + } else { + $b1r{$id} = $real; + $b1v{$id} = $virtual; +} } close(B1); $_ = ''; @@ -83,14 +99,23 @@ parse(); while () { parse(); next unless (defined($id)); - $b2r{$id} = $real; - $b2v{$id} = $virtual; + if(defined($b2r{$id})) { + print STDERR "More than one benchmark for $id in file 2\n"; + if($real > $b2r{$id} || ($real == $b2r{$id} && $virtual > $b2v{$id})) { + $b2r{$id} = $real; + $b2v{$id} = $virtual; + } + } else { + $b2r{$id} = $real; + $b2v{$id} = $virtual; + } } close(B2); foreach $id (keys %b1r) { if (!defined($b2r{$id})) { print "Only in file 1: $id\n"; + $onlyin1 += 1; next; } } @@ -101,6 +126,12 @@ $n = 0; foreach $id (keys %b2r) { if (!defined($b1r{$id})) { print "Only in file 2: $id\n"; + $onlyin2 += 1; + next; + } +} +foreach $id (keys %b2r) { + if (!defined($b1r{$id})) { next; } my $kr = $b2r{$id} / $b1r{$id}; @@ -114,8 +145,14 @@ foreach $id (keys %b2r) { $mr *= $kr; $mv *= $kv; $n++; + if ($verbose == 1) { + printf "Ratio:\t%.5f real, %.5f virtual\t$id\n", $kr, $kv; + } +} +if ($onlyin1 != 0 && $onlyin2 != 0) { + print STDERR "Converting the two benchmark files using benchmark-unify might\n"; + print STDERR "increase the number of benchmarks which can be compared\n"; } - print "Number of benchmarks:\t\t$n\n"; exit unless ($n); -- 1.7.7.6