[commit: containers] master: Scripts for comparing csv results of benchmarks. (12d03eb)

Paolo Capriotti <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.libraries
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/packages/containers

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/12d03ebd2755f6acb78516d8f7ca5954b1e76cb0

>---------------------------------------------------------------

commit 12d03ebd2755f6acb78516d8f7ca5954b1e76cb0
Author: Milan Straka <[email protected]>
Date:   Sat Apr 14 18:40:31 2012 +0200

    Scripts for comparing csv results of benchmarks.

>---------------------------------------------------------------

 .gitignore              |    1 +
 benchmarks/Makefile     |    2 +-
 benchmarks/bench-cmp.pl |   24 ++++++++++++++++++++++++
 benchmarks/bench-cmp.sh |    3 +++
 4 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/.gitignore b/.gitignore
index f5c7aee..e80379d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
 *.tix
 .hpc/
 /dist/*
+/benchmarks/*.csv
 GNUmakefile
 dist-install
 ghc.mk
diff --git a/benchmarks/Makefile b/benchmarks/Makefile
index 00e52a1..de6f612 100644
--- a/benchmarks/Makefile
+++ b/benchmarks/Makefile
@@ -11,4 +11,4 @@ clean:
 	rm -rf tmp $(patsubst %.hs, bench-%, $(wildcard *.hs))
 
 veryclean: clean
-	rm -rf $(patsubst %.hs, bench-%.csv, $(wildcard *.hs))
+	rm -rf *.csv
diff --git a/benchmarks/bench-cmp.pl b/benchmarks/bench-cmp.pl
new file mode 100755
index 0000000..b1864c7
--- /dev/null
+++ b/benchmarks/bench-cmp.pl
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+@ARGV >= 2 or die "Usage: bench-cmp.pl csv_file_1 csv_file_2";
+open (my $f1, "<", $ARGV[0]) or die "Cannot open file $ARGV[0]";
+open (my $f2, "<", $ARGV[1]) or die "Cannot open file $ARGV[1]";
+
+my $l1 = <$f1>;
+my $l2 = <$f2>;
+$l1 eq $l2 or die "CSV files do not correspond -- $l1 and $l2";
+
+while (defined($l1 = <$f1>)) {
+  $l2 = <$f2>;
+
+  my @parts1 = split /,/, $l1;
+  my @parts2 = split /,/, $l2;
+
+  $parts1[0] eq $parts2[0] or die "CSV files do not correspond -- $parts1[0] and $parts2[0]";
+  printf "%s;%+7.2f%%;%.2e\n", $parts1[0], 100 * $parts2[1] / $parts1[1] - 100, $parts1[1];
+}
+
+close $f2;
+close $f1;
diff --git a/benchmarks/bench-cmp.sh b/benchmarks/bench-cmp.sh
new file mode 100755
index 0000000..157b578
--- /dev/null
+++ b/benchmarks/bench-cmp.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+./bench-cmp.pl "$@" | column -nts\; | less -SR
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.