aboutsummaryrefslogtreecommitdiffstats
path: root/bench/merge-benchmark-func.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-func.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-func.py')
-rwxr-xr-xbench/merge-benchmark-func.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/bench/merge-benchmark-func.py b/bench/merge-benchmark-func.py
new file mode 100755
index 0000000..c1b66eb
--- /dev/null
+++ b/bench/merge-benchmark-func.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python3
+# See LICENSE file for copyright and license details.
+
+
+# Invoke using `env SELECT_MIN=` to select the minimum value,
+# rather than concatenate. This applies to 1-dimensional data only.
+
+
+import sys, os
+
+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)
+
+dim = int(files[0][1])
+skip = 1 + dim
+for i in range(skip):
+ print(files[0][i])
+
+if dim > 1:
+ for i in range(skip, line_count):
+ best_nsec = None
+ best_line = None
+ for lines in files:
+ line = lines[i]
+ nsec = int(line)
+ if best_nsec is None or nsec < best_nsec:
+ best_nsec, best_line = nsec, line
+ print(best_line)
+else 'SELECT_MIN' not in os.environ:
+ for lines in files:
+ for i in range(skip, line_count):
+ print(lines[i])
+else:
+ best_nsec = None
+ best_line = None
+ for lines in files:
+ for i in range(skip, line_count):
+ line = lines[i]
+ nsec = int(line)
+ if best_nsec is None or nsec < best_nsec:
+ best_nsec, best_line = nsec, line
+ print(best_line)