2021-05-08 21:38:39 +02:00
|
|
|
import json
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
def to_dict_key(key: str):
|
|
|
|
for r in [" ", ":", "-"]:
|
|
|
|
key = key.replace(r, "_")
|
|
|
|
for r in ["(", ")"]:
|
|
|
|
key = key.replace(r, "")
|
|
|
|
return key
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2021-08-18 20:56:33 -07:00
|
|
|
from ray._private.ray_perf import main
|
2022-01-29 18:41:57 -08:00
|
|
|
|
2021-05-08 21:38:39 +02:00
|
|
|
results = main() or []
|
|
|
|
|
|
|
|
result_dict = {
|
2022-01-29 18:41:57 -08:00
|
|
|
f"{to_dict_key(v[0])}": (v[1], v[2]) for v in results if v is not None
|
2021-05-08 21:38:39 +02:00
|
|
|
}
|
|
|
|
|
2022-03-02 06:19:31 -08:00
|
|
|
perf_metrics = [
|
|
|
|
{
|
|
|
|
"perf_metric_name": to_dict_key(v[0]),
|
|
|
|
"perf_metric_value": v[1],
|
|
|
|
"perf_metric_type": "THROUGHPUT",
|
|
|
|
}
|
|
|
|
for v in results
|
|
|
|
if v is not None
|
|
|
|
]
|
|
|
|
result_dict["perf_metrics"] = perf_metrics
|
|
|
|
|
2022-01-29 18:41:57 -08:00
|
|
|
test_output_json = os.environ.get("TEST_OUTPUT_JSON", "/tmp/microbenchmark.json")
|
2021-05-08 21:38:39 +02:00
|
|
|
|
|
|
|
with open(test_output_json, "wt") as f:
|
|
|
|
json.dump(result_dict, f)
|