aboutsummaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2018-09-04 10:58:54 -0700
committerJosh Haberman <jhaberman@gmail.com>2018-09-04 10:58:54 -0700
commitd61aede89cf188367766b971f59cf57d7835d8e8 (patch)
treea19842c62c3c8f51389912ecafdf932d0a572bea /benchmarks
parent45d03a977193d1dcce5251e4bffe17bf0ba738ec (diff)
downloadprotobuf-d61aede89cf188367766b971f59cf57d7835d8e8.tar.gz
protobuf-d61aede89cf188367766b971f59cf57d7835d8e8.tar.bz2
protobuf-d61aede89cf188367766b971f59cf57d7835d8e8.zip
Down-integrate from google3.
Diffstat (limited to 'benchmarks')
-rwxr-xr-xbenchmarks/util/result_parser.py46
1 files changed, 42 insertions, 4 deletions
diff --git a/benchmarks/util/result_parser.py b/benchmarks/util/result_parser.py
index a843923a..32f35a97 100755
--- a/benchmarks/util/result_parser.py
+++ b/benchmarks/util/result_parser.py
@@ -45,9 +45,10 @@ __results = []
# "benchmarks": [
# {
# "bytes_per_second": int,
-# "cpu_time": int,
+# "cpu_time_ns": double,
+# "iterations": int,
# "name: string,
-# "time_unit: string,
+# "real_time_ns: double,
# ...
# },
# ...
@@ -75,6 +76,36 @@ def __parse_cpp_result(filename):
})
+# Synthetic benchmark results example:
+# [
+# "benchmarks": [
+# {
+# "cpu_time_ns": double,
+# "iterations": int,
+# "name: string,
+# "real_time_ns: double,
+# ...
+# },
+# ...
+# ],
+# ...
+# ]
+def __parse_synthetic_result(filename):
+ if filename == "":
+ return
+ if filename[0] != "/":
+ filename = os.path.dirname(os.path.abspath(__file__)) + "/" + filename
+ with open(filename) as f:
+ results = json.loads(f.read())
+ for benchmark in results["benchmarks"]:
+ __results.append({
+ "language": "cpp",
+ "dataFilename": "",
+ "behavior": "synthetic",
+ "throughput": 10.0**9 / benchmark["cpu_time_ns"]
+ })
+
+
# Python results example:
# [
# [
@@ -204,7 +235,12 @@ def __parse_go_result(filename):
"language": "go"
})
-def get_result_from_file(cpp_file="", java_file="", python_file="", go_file=""):
+
+def get_result_from_file(cpp_file="",
+ java_file="",
+ python_file="",
+ go_file="",
+ synthetic_file=""):
results = {}
if cpp_file != "":
__parse_cpp_result(cpp_file)
@@ -214,5 +250,7 @@ def get_result_from_file(cpp_file="", java_file="", python_file="", go_file=""):
__parse_python_result(python_file)
if go_file != "":
__parse_go_result(go_file)
+ if synthetic_file != "":
+ __parse_synthetic_result(synthetic_file)
- return __results \ No newline at end of file
+ return __results