run_microbenchmark.py 841 B

123456789101112131415161718192021222324252627282930313233343536
  1. import json
  2. import os
  3. def to_dict_key(key: str):
  4. for r in [" ", ":", "-"]:
  5. key = key.replace(r, "_")
  6. for r in ["(", ")"]:
  7. key = key.replace(r, "")
  8. return key
  9. if __name__ == "__main__":
  10. from ray._private.ray_perf import main
  11. results = main() or []
  12. result_dict = {
  13. f"{to_dict_key(v[0])}": (v[1], v[2]) for v in results if v is not None
  14. }
  15. perf_metrics = [
  16. {
  17. "perf_metric_name": to_dict_key(v[0]),
  18. "perf_metric_value": v[1],
  19. "perf_metric_type": "THROUGHPUT",
  20. }
  21. for v in results
  22. if v is not None
  23. ]
  24. result_dict["perf_metrics"] = perf_metrics
  25. test_output_json = os.environ.get("TEST_OUTPUT_JSON", "/tmp/microbenchmark.json")
  26. with open(test_output_json, "wt") as f:
  27. json.dump(result_dict, f)