llvm-project
86 строк · 2.6 Кб
1#!@Python3_EXECUTABLE@
2# -*- coding: utf-8 -*-
3
4import argparse
5import datetime
6import json
7import os
8import sys
9
10from urllib import error as urlerror
11from urllib import parse as urlparse
12from urllib import request
13
14
15mlir_source_root = "@MLIR_SOURCE_DIR@"
16sys.path.insert(0, os.path.join(mlir_source_root, "utils", "mbr", "mbr"))
17
18from main import main
19
20
21if __name__ == "__main__":
22parser = argparse.ArgumentParser()
23parser.add_argument(
24"--machine",
25required=True,
26help="A platform identifier on which the "
27"benchmarks are run. For example"
28" <hardware>-<arch>-<optimization level>-<branch-name>"
29)
30parser.add_argument(
31"--revision",
32required=True,
33help="The key used to identify different runs. "
34"Could be anything as long as it"
35" can be sorted by python's sort function"
36)
37parser.add_argument(
38"--url",
39help="The lnt server url to send the results to",
40default="http://localhost:8000/db_default/v4/nts/submitRun"
41)
42parser.add_argument(
43"--result-stdout",
44help="Print benchmarking results to stdout instead"
45" of sending it to lnt",
46default=False,
47action=argparse.BooleanOptionalAction
48)
49parser.add_argument(
50"top_level_path",
51help="The top level path from which to search for benchmarks",
52default=os.getcwd(),
53)
54parser.add_argument(
55"--stop_on_error",
56help="Should we stop the benchmark run on errors? Defaults to false",
57default=False,
58)
59args = parser.parse_args()
60
61complete_benchmark_start_time = datetime.datetime.utcnow().isoformat()
62benchmark_function_dicts = main(args.top_level_path, args.stop_on_error)
63complete_benchmark_end_time = datetime.datetime.utcnow().isoformat()
64lnt_dict = {
65"format_version": "2",
66"machine": {"name": args.machine},
67"run": {
68"end_time": complete_benchmark_start_time,
69"start_time": complete_benchmark_end_time,
70"llvm_project_revision": args.revision
71},
72"tests": benchmark_function_dicts,
73"name": "MLIR benchmark suite"
74}
75lnt_json = json.dumps(lnt_dict, indent=4)
76if args.result_stdout is True:
77print(lnt_json)
78else:
79request_data = urlparse.urlencode(
80{"input_data": lnt_json}
81).encode("ascii")
82req = request.Request(args.url, request_data)
83try:
84resp = request.urlopen(req)
85except urlerror.HTTPError as e:
86print(e)
87