Skip to content

Commit

Permalink
Support saving test data to .csv as well as .json.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Jeffrey committed Nov 15, 2017
1 parent 40adc3f commit d817b22
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion etc/ci/performance/runner.py
Expand Up @@ -5,6 +5,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import argparse
import csv
import itertools
import json
import os
Expand Down Expand Up @@ -236,6 +237,40 @@ def save_result_json(results, filename, manifest, expected_runs, base):
print("Result saved to {}".format(filename))


def save_result_csv(results, filename, manifest, expected_runs, base):

fieldnames = [
'testcase',
'title',
'connectEnd',
'connectStart',
'domComplete',
'domContentLoadedEventEnd',
'domContentLoadedEventStart',
'domInteractive',
'domLoading',
'domainLookupEnd',
'domainLookupStart',
'fetchStart',
'loadEventEnd',
'loadEventStart',
'navigationStart',
'redirectEnd',
'redirectStart',
'requestStart',
'responseEnd',
'responseStart',
'secureConnectionStart',
'unloadEventEnd',
'unloadEventStart',
]

with open(filename, 'w') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames)
writer.writeheader()
writer.writerows(results)


def format_result_summary(results):
failures = list(filter(lambda x: x['domComplete'] == -1, results))
result_log = """
Expand Down Expand Up @@ -306,7 +341,10 @@ def main():
# TODO: Record and analyze other performance.timing properties

print(format_result_summary(results))
save_result_json(results, args.output_file, testcases, args.runs, args.base)
if args.output_file.endswith('.csv'):
save_result_csv(results, args.output_file, testcases, args.runs, args.base)
else:
save_result_json(results, args.output_file, testcases, args.runs, args.base)

except KeyboardInterrupt:
print("Test stopped by user, saving partial result")
Expand Down

0 comments on commit d817b22

Please sign in to comment.