9 sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))
11 import tmp.benchmarks_pb2
as benchmarks_pb2
16 if filename[0] !=
'/':
17 filename = os.path.dirname(os.path.abspath(__file__)) +
"/../" + filename
18 if filename
in __file_size_map:
19 return __file_size_map[filename]
20 benchmark_dataset = benchmarks_pb2.BenchmarkDataset()
21 benchmark_dataset.ParseFromString(
25 for payload
in benchmark_dataset.payload:
28 __file_size_map[filename] = (size, 1.0 * size / count)
29 return size, 1.0 * size / count
33 name_list = re.split(
r"[/\.]", file_name)
35 for name
in name_list:
36 if name[:14] ==
"google_message":
37 short_file_name = name
38 return short_file_name
62 if filename[0] !=
'/':
63 filename = os.path.dirname(os.path.abspath(__file__)) +
'/' + filename
64 with open(filename, encoding=
"utf-8")
as f:
65 results = json.loads(f.read())
66 for benchmark
in results[
"benchmarks"]:
67 data_filename =
"".join(
68 re.split(
"(_parse_|_serialize)", benchmark[
"name"])[0])
69 behavior = benchmark[
"name"][
len(data_filename) + 1:]
70 if data_filename[:2] ==
"BM":
71 data_filename = data_filename[3:]
74 "dataFilename": data_filename,
76 "throughput": benchmark[
"bytes_per_second"] / 2.0 ** 20
97 if filename[0] !=
"/":
98 filename = os.path.dirname(os.path.abspath(__file__)) +
"/" + filename
99 with open(filename, encoding=
"utf-8")
as f:
100 results = json.loads(f.read())
101 for benchmark
in results[
"benchmarks"]:
105 "behavior":
"synthetic",
106 "throughput": 10.0**9 / benchmark[
"cpu_time_ns"]
127 if filename[0] !=
'/':
128 filename = os.path.dirname(os.path.abspath(__file__)) +
'/' + filename
129 with open(filename, encoding=
"utf-8")
as f:
130 results_list = json.loads(f.read())
131 for results
in results_list:
132 for result
in results:
134 for behavior
in result[
"benchmarks"]:
136 "language":
"python",
138 "behavior": behavior,
139 "throughput": result[
"benchmarks"][behavior]
177 if filename[0] !=
'/':
178 filename = os.path.dirname(os.path.abspath(__file__)) +
'/' + filename
179 with open(filename, encoding=
"utf-8")
as f:
180 results = json.loads(f.read())
181 for result
in results:
184 for measurement
in result[
"measurements"]:
185 total_weight += measurement[
"weight"]
186 total_value += measurement[
"value"][
"magnitude"]
187 avg_time = total_value * 1.0 / total_weight
189 result[
"scenario"][
"benchmarkSpec"][
"parameters"][
"dataFile"])
192 "throughput": total_size / avg_time * 1e9 / 2 ** 20,
193 "behavior": result[
"scenario"][
"benchmarkSpec"][
"methodName"],
195 result[
"scenario"][
"benchmarkSpec"][
"parameters"][
"dataFile"])
213 if filename[0] !=
'/':
214 filename = os.path.dirname(os.path.abspath(__file__)) +
'/' + filename
215 with open(filename, encoding=
"utf-8")
as f:
217 result_list = re.split(
r"[\ \t]+", line)
218 if result_list[0][:9] !=
"Benchmark":
220 first_slash_index = result_list[0].
find(
'/')
221 last_slash_index = result_list[0].rfind(
'/')
222 full_filename = result_list[0][first_slash_index+1:last_slash_index]
224 behavior_with_suffix = result_list[0][last_slash_index+1:]
225 last_dash = behavior_with_suffix.rfind(
"-")
227 behavior = behavior_with_suffix
229 behavior = behavior_with_suffix[:last_dash]
232 "throughput": total_bytes / float(result_list[2]) * 1e9 / 2 ** 20,
233 "behavior": behavior,
253 if filename[0] !=
'/':
254 filename = os.path.dirname(os.path.abspath(__file__)) +
'/' + filename
255 with open(filename, encoding=
"utf-8")
as f:
256 results = json.loads(f.read())
257 for result
in results:
259 for behavior
in result[
"benchmarks"]:
261 "language": language,
263 "behavior": behavior,
264 "throughput": result[
"benchmarks"][behavior]
288 if python_file !=
"":
292 if synthetic_file !=
"":
304 if __name__ ==
"__main__":
305 parser = argparse.ArgumentParser()
309 help=
"The CPP benchmark result file's name",
314 help=
"The Java benchmark result file's name",
318 "--python_input_file",
319 help=
"The Python benchmark result file's name",
324 help=
"The golang benchmark result file's name",
329 help=
"The node.js benchmark result file's name",
334 help=
"The pure php benchmark result file's name",
338 "--php_c_input_file",
339 help=
"The php with c ext benchmark result file's name",
341 args = parser.parse_args()
344 cpp_file=args.cpp_input_file,
345 java_file=args.java_input_file,
346 python_file=args.python_input_file,
347 go_file=args.go_input_file,
348 node_file=args.node_input_file,
349 php_file=args.php_input_file,
350 php_c_file=args.php_c_input_file,
352 print(json.dumps(results, indent=2))