MCPcopy Create free account
hub / github.com/GPflow/GPflow / run

Function run

benchmark/run.py:249–301  ·  view source on GitHub ↗

Collect data for a benchmark suite.

(
    shard: ShardingStrategy,
    suite: BenchmarkSuite,
    dest: Path,
    no_subdir: bool,
    cache_dir: Path,
    plot: bool,
)

Source from the content-addressed store, hash-verified

247
248
249def run(
250 shard: ShardingStrategy,
251 suite: BenchmarkSuite,
252 dest: Path,
253 no_subdir: bool,
254 cache_dir: Path,
255 plot: bool,
256) -> None:
257 """ Collect data for a benchmark suite. """
258 if shard.setup_dest:
259 metadata = BenchmarkMetadata.create(suite.name)
260 dest = setup_dest(metadata, dest, no_subdir)
261 else:
262 assert no_subdir, "Must use 'no-subdir=True' with 'shard={shard}'."
263 with open(dest / "metadata.json", "rt") as f:
264 metadata = BenchmarkMetadata.from_json(json.load(f))
265 assert metadata.suite_name == suite.name
266 metadata = metadata.for_shard()
267
268 if shard.print_dest:
269 print(dest.resolve())
270
271 if shard.write_metadata:
272 metadata_path = dest / f"metadata{shard.file_suffix}.json"
273 with open(metadata_path, "wt") as f:
274 json.dump(metadata.to_json(), f, indent=4)
275
276 metrics_df: Optional[pd.DataFrame] = None
277
278 if shard.run_benchmarks:
279 metrics_df = _run_benchmarks(
280 metadata,
281 shard,
282 suite,
283 dest,
284 cache_dir,
285 )
286
287 if shard.collect:
288 assert metrics_df is None
289 metrics_path = dest / "metrics.csv"
290 metrics_df_list = [pd.read_csv(p) for p in shard.find_shards(metrics_path)]
291 metrics_df = pd.concat(metrics_df_list, axis="index", ignore_index=True)
292 metrics_df.to_csv(metrics_path, index=False)
293
294 if shard.plot and plot and (metrics_df is not None):
295 plot_(
296 metadata=metadata,
297 suite=suite,
298 results_df=metrics_df,
299 results_metadata=[metadata],
300 dest=dest,
301 )
302
303
304def run_from_argv() -> None:

Callers 2

test_benchmarkFunction · 0.90
run_from_argvFunction · 0.85

Calls 7

setup_destFunction · 0.90
_run_benchmarksFunction · 0.85
createMethod · 0.80
from_jsonMethod · 0.80
for_shardMethod · 0.80
to_jsonMethod · 0.80
find_shardsMethod · 0.80

Tested by 1

test_benchmarkFunction · 0.72