aboutsummaryrefslogtreecommitdiff
path: root/merge.py
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-11-23 00:08:18 +0100
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-11-23 00:08:18 +0100
commit00f74bd822dda4b39ed439f53e0767283f85c5e5 (patch)
tree971dc58fb99f78e00ba17e56de7a826dfed9e862 /merge.py
parent8c2ef987bb90b4624ea684458f35b8ca7d2e04c0 (diff)
downloadallocbench-00f74bd822dda4b39ed439f53e0767283f85c5e5.tar.gz
allocbench-00f74bd822dda4b39ed439f53e0767283f85c5e5.zip
change result format from pickle to json
Diffstat (limited to 'merge.py')
-rwxr-xr-xmerge.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/merge.py b/merge.py
index a8b2afb..f3376fa 100755
--- a/merge.py
+++ b/merge.py
@@ -20,12 +20,21 @@
"""Merge two compatible results of an allocbench run"""
import argparse
+import json
import os
import pickle
import sys
from src.util import print_license_and_exit, print_version_and_exit
+def load_file(filename):
+ if filename.endswith("json"):
+ with open(filename, "r") as f:
+ return json.load(f)
+ else:
+ with open(filename, "rb") as f:
+ return pickle.load(f)
+
def main():
if "--license" in sys.argv:
@@ -61,11 +70,9 @@ def main():
print(f"Can't merge {src_save} because {os.path.basename(src_save)} not in {args.dest}")
continue
- with open(src_save, "rb") as src_file:
- src_results = pickle.load(src_file)
+ src_results = load_file(src_file)
- with open(dest_save, "rb") as dest_file:
- dest_results = pickle.load(dest_file)
+ dest_results = load_file(dest_file)
for alloc in src_results["allocators"]:
if alloc in dest_results["allocators"]:
@@ -77,8 +84,8 @@ def main():
dest_results[alloc] = src_results[alloc]
dest_results["stats"][alloc] = src_results["stats"][alloc]
- with open(dest_save, "wb") as result_file:
- pickle.dump(dest_results, result_file)
+ with open(os.path.splitext(dest_save)[0] + ".json", "w") as result_file:
+ json.dump(dest_results, result_file)
if __name__ == "__main__":