class_docstr: Utility class used for Ray Data release tests and benchmarks, which works
  for both local and distributed benchmarking. When run on the nightly release
  test pipeline, the results are written to our internal database, which
  can then be rendered on the dashboard. Usage tips:
  
  A typical workflow would be:
  
  benchmark = Benchmark("benchmark-name")
  
  # set up (such as input read or generation)
  ...
  
  benchmark.run_materialize_ds("case-1", fn_1)
  # Could be Ray Data iterator, Torch DataLoader, TF Dataset...
  benchmark.run_iterate_ds("case-2", dataset)
  benchmark.run_fn("case-3", fn_3)
  
  # Writes a JSON with metrics of the form:
  # {"case-1": {...}, "case-2": {...}, "case-3": {...}}
  benchmark.write_result()
  
  See example usage in ``aggregate_benchmark.py``.
class_docstr_tok: ["Utility","class","used","for","Ray","Data","release","tests","and","benchmarks",",","which","works","for","both","local","and","distributed","benchmarking",".","When","run","on","the","nightly","release","test","pipeline",",","the","results","are","written","to","our","internal","database",",","which","can","then","be","rendered","on","the","dashboard",".","Usage","tips",":","A","typical","workflow","would","be",":","benchmark","=","Benchmark","(","``","benchmark-name","''",")","#","set","up","(","such","as","input","read","or","generation",")","...","benchmark.run_materialize_ds","(","``","case-1","''",",","fn_1",")","#","Could","be","Ray","Data","iterator",",","Torch","DataLoader",",","TF","Dataset","...","benchmark.run_iterate_ds","(","``","case-2","''",",","dataset",")","benchmark.run_fn","(","``","case-3","''",",","fn_3",")","#","Writes","a","JSON","with","metrics","of","the","form",":","#","{","``","case-1","''",":","{","...","}",",","``","case-2","''",":","{","...","}",",","``","case-3","''",":","{","...","}","}","benchmark.write_result","(",")","See","example","usage","in","``","aggregate_benchmark.py","``","."]
docstr: Write all collected benchmark results to `output_path`.
  The result is a dict of the form:
  ``{case_name: {metric_name: metric_value, ...}}``.
docstr_tok: ["Write","all","collected","benchmark","results","to","`","output_path","`",".","The","result","is","a","dict","of","the","form",":","``","{","case_name",":","{","metric_name",":","metric_value",",","...","}","}","``","."]
code: def write_result(self, output_path="/tmp/result.json"):
      """Write all collected benchmark results to `output_path`.
      The result is a dict of the form:
      ``{case_name: {metric_name: metric_value, ...}}``."""
  
      test_output_json = os.environ.get("TEST_OUTPUT_JSON", output_path)
      with open(test_output_json, "w") as f:
          self.result["name"] = self.name
          f.write(json.dumps(self.result))
  
      print(
          f"Finished benchmark {self.name}, metrics exported to {test_output_json}:"
      )
      print(self.result)
  
file_path: ray/release/nightly_tests/dataset/benchmark.py
imports: import gc
  import json
  import os
  import time
  from typing import Callable, Dict
  from ray.data.dataset import Dataset
  from typing import Any
  from enum import Enum
  import pyarrow
  import pandas
label_desc: Use image node_id 5 for calling the Benchmark obj's underlying member method code with example usage: obj.write_result(output_path) without return types