CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
51 lines
2.2 KiB
Python
Executable File
51 lines
2.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
import csv
|
|
import json
|
|
import sys
|
|
|
|
def main(argv):
|
|
parser = argparse.ArgumentParser(
|
|
prog='parse-google-benchmark-results',
|
|
description='Parse Google Benchmark result files (in JSON format) into CSV or LNT compatible output.')
|
|
parser.add_argument('filename', type=argparse.FileType('r'), nargs='+',
|
|
help='One of more JSON files to extract the results from. The results parsed from each '
|
|
'file are concatenated together.')
|
|
parser.add_argument('--timing', type=str, choices=['real_time', 'cpu_time'], default='real_time',
|
|
help='The timing to extract from the Google Benchmark results. This can either be the '
|
|
'"real time" or the "CPU time". Default is "real time".')
|
|
parser.add_argument('--output-format', type=str, choices=['csv', 'lnt'], default='csv',
|
|
help='The desired output format for the data. `csv` is CSV format and `lnt` is a format compatible with '
|
|
'`lnt importreport` (see https://llvm.org/docs/lnt/importing_data.html#importing-data-in-a-text-file).')
|
|
args = parser.parse_args(argv)
|
|
|
|
# Parse the data from all files, aggregating the results
|
|
headers = ['Benchmark', args.timing]
|
|
rows = []
|
|
for file in args.filename:
|
|
js = json.load(file)
|
|
for bm in js['benchmarks']:
|
|
if args.timing not in bm:
|
|
raise RuntimeError(f'Benchmark does not contain key for {args.timing}: {bm}')
|
|
row = [bm['name'], bm[args.timing]]
|
|
rows.append(row)
|
|
|
|
# Print the results in the right format
|
|
if args.output_format == 'csv':
|
|
writer = csv.writer(sys.stdout)
|
|
writer.writerow(headers)
|
|
for row in rows:
|
|
writer.writerow(row)
|
|
elif args.output_format == 'lnt':
|
|
benchmark = headers.index('Benchmark')
|
|
time = headers.index(args.timing)
|
|
for row in rows:
|
|
# LNT format uses '.' to separate the benchmark name from the metric, and ' '
|
|
# to separate the benchmark name + metric from the numerical value. Escape both.
|
|
escaped = row[benchmark].replace(".", "_").replace(" ", "_")
|
|
print(f'{escaped}.execution_time {row[time]}')
|
|
|
|
if __name__ == '__main__':
|
|
main(sys.argv[1:])
|