aboutsummaryrefslogtreecommitdiffstats
path: root/bench/merge-benchmark.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-05-01 23:21:27 +0200
committerMattias Andrée <maandree@kth.se>2016-05-01 23:21:27 +0200
commit068fc72f804ef972a35f06b06b049a84db1ce6a7 (patch)
treef789abbb720db0e4b45e2547bae2b7a568efd818 /bench/merge-benchmark.py
parentComments from 1-bit 4097-bit benchmarks (diff)
downloadlibzahl-068fc72f804ef972a35f06b06b049a84db1ce6a7.tar.gz
libzahl-068fc72f804ef972a35f06b06b049a84db1ce6a7.tar.bz2
libzahl-068fc72f804ef972a35f06b06b049a84db1ce6a7.tar.xz
Benchmarking stuff
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'bench/merge-benchmark.py')
-rwxr-xr-xbench/merge-benchmark.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/bench/merge-benchmark.py b/bench/merge-benchmark.py
new file mode 100755
index 0000000..aeb5eac
--- /dev/null
+++ b/bench/merge-benchmark.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python3
+# See LICENSE file for copyright and license details.
+
+import sys
+
+line_count = None
+files = []
+
+for path in sys.argv[1:]:
+ with open(path, 'rb') as file:
+ data = file.read()
+ data = data.decode('utf-8', 'strict')
+ if data[-1] == '\n':
+ data = data[:-1]
+ data = data.split('\n')
+ if line_count is None:
+ line_count = len(data)
+ elif len(data) != line_count:
+ print('%s: line count mismatch' % sys.argv[0], file = sys.stderr)
+ sys.exit(1)
+ files.append(data)
+
+for i in range(line_count):
+ best_sec = None
+ best_nsec = None
+ best_line = None
+ for lines in files:
+ line = lines[i]
+ [sec, nsec] = line.split(':')[1].split(' ')[1].split('.')
+ [sec, nsec] = [int(sec), int(nsec)]
+ if best_sec is None or sec < best_sec or (sec == best_sec and nsec < best_nsec):
+ best_sec, best_nsec, best_line = sec, nsec, line
+ print(best_line)