MCPcopy Create free account
hub / github.com/PythonOT/POT / exec_bench

Function exec_bench

benchmarks/benchmark.py:20–49  ·  view source on GitHub ↗
(setup, tested_function, param_list, n_runs, warmup_runs)

Source from the content-addressed store, hash-verified

18
19
20def exec_bench(setup, tested_function, param_list, n_runs, warmup_runs):
21 backend_list = get_backend_list()
22 for i, nx in enumerate(backend_list):
23 if nx.__name__ == "tf" and i < len(backend_list) - 1:
24 # Tensorflow should be the last one to be benchmarked because
25 # as far as I'm aware, there is no way to force it to release
26 # GPU memory. Hence, if any other backend is benchmarked after
27 # Tensorflow and requires the usage of a GPU, it will not have the
28 # full memory available and you may have a GPU Out Of Memory error
29 # even though your GPU can technically hold your tensors in memory.
30 backend_list.pop(i)
31 backend_list.append(nx)
32 break
33
34 inputs = [setup(param) for param in param_list]
35 results = dict()
36 for nx in backend_list:
37 for i in range(len(param_list)):
38 print(nx, param_list[i])
39 args = inputs[i]
40 results_nx = nx._bench(
41 tested_function, *args, n_runs=n_runs, warmup_runs=warmup_runs
42 )
43 gc.collect()
44 results_nx_with_param_in_key = dict()
45 for key in results_nx:
46 new_key = (param_list[i], *key)
47 results_nx_with_param_in_key[new_key] = results_nx[key]
48 results.update(results_nx_with_param_in_key)
49 return results
50
51
52def convert_to_html_table(results, param_name, main_title=None, comments=None):

Callers 2

sinkhorn_knopp.pyFile · 0.85
emd.pyFile · 0.85

Calls 3

get_backend_listFunction · 0.90
setupFunction · 0.70
_benchMethod · 0.45

Tested by

no test coverage detected