Commit 8e9a0d7b authored by Matthias Linhuber's avatar Matthias Linhuber
Browse files

Implement JSON export

parent 7bc227af
......@@ -2,6 +2,8 @@ import math
import subprocess
import argparse
import json
import platform
from datetime import datetime
from pprint import pprint
from prettytable import PrettyTable
......@@ -133,11 +135,12 @@ class ResultManager:
"""
self.testers = testers
self.repetitions = repetitions
self.jsonRepetition = {}
def printResults(self,
human=False,
table=True,
showAllRepetitions=True):
human=False,
table=True,
showAllRepetitions=True):
"""Prints the testresults to the command prompt.
Parameters:
......@@ -202,12 +205,28 @@ class ResultManager:
print(heading)
pprint(results)
def _generateJsonRepresentation(self):
if len(self.jsonRepetition) == 0:
self.jsonRepetition = [x.getJsonRepresentation()
for x in self.testers]
def exportJsonToFile(self, filename):
raise NotImplementedError()
if len(filename) == 0:
dateTimeObj = datetime.now()
filename = str(platform.node()) + "_" + str(dateTimeObj) + ".json"
print(filename)
self._generateJsonRepresentation()
o = json.dumps(self.jsonRepetition, indent=4)
open(filename, "w").write(o)
def printJson(self):
results = [x.getJsonRepresentation() for x in self.testers]
s = print(json.dumps(results, indent=4))
self._generateJsonRepresentation()
print(json.dumps(self.jsonRepetition, indent=4))
def main():
......@@ -226,6 +245,9 @@ def main():
help="Show the test-results in non-table format")
parser.add_argument("--brief", action="store_true",
default=False, help="Show only average")
parser.add_argument("--storeResult", action="store_true",
default=False, help="Store Results to disk (as JSON)")
parser.add_argument("--outputFile", "-o", default="")
parser.add_argument(
"--fileSize", choices=["1G", "2G", "5G", "10G"], default="2G",
help="Define desired fileSize for all parameter sets - NOT IMPLEMENTED")
......@@ -268,6 +290,8 @@ def main():
resultManager.printResults(human=args.human,
table=not args.raw,
showAllRepetitions=not args.brief)
if args.storeResult or len(args.outputFile) > 0:
resultManager.exportJsonToFile(args.outputFile)
main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment