diff --git a/docs/benchmarks.rst b/docs/benchmarks.rst index b6d959395b740779f00bfd19e35b3261baba5dc6_ZG9jcy9iZW5jaG1hcmtzLnJzdA==..172976da909be7cce58a5ea6a1ec44bff4cc5a92_ZG9jcy9iZW5jaG1hcmtzLnJzdA== 100644 --- a/docs/benchmarks.rst +++ b/docs/benchmarks.rst @@ -37,6 +37,7 @@ The current list of supported method is : :simple-command: benchmarking the run of a single shell command. +:mercurial-perf-extension: using Mercurial perf extensions to run benchmarks Simple-command configuration ============================ @@ -106,3 +107,19 @@ ~~~ overwrite the global `simple-command.cwd` variable. Behave the same. + +Mercurial perf extensions configuration +======================================= + +section: "hg-perf-ext" +---------------------- + +cwd +~~~ + +Same as for simple-command extension. + +command +~~~~~~~ + +The perf-command to use. diff --git a/python-libs/poulpe/runner.py b/python-libs/poulpe/runner.py index b6d959395b740779f00bfd19e35b3261baba5dc6_cHl0aG9uLWxpYnMvcG91bHBlL3J1bm5lci5weQ==..172976da909be7cce58a5ea6a1ec44bff4cc5a92_cHl0aG9uLWxpYnMvcG91bHBlL3J1bm5lci5weQ== 100644 --- a/python-libs/poulpe/runner.py +++ b/python-libs/poulpe/runner.py @@ -6,6 +6,41 @@ import poulpe +def run_one(bin_env_path, data_env_path, benchmark_path, result): + result_data = {} + result_data['run'] = {} + result_data['run']["timestamp"] = time.time() + + # gather info about the binary environment + bin_env_desc = poulpe.bin_env_file(bin_env_path) + bin_env_data = poulpe.get_data(bin_env_desc) + result_data['bin-env-vars'] = bin_env_data['bin-env-vars'] + + # gather info about the data environment + data_env_desc = poulpe.data_env_file(data_env_path) + data_env_data = poulpe.get_data(data_env_desc) + result_data['data-env-vars'] = data_env_data['data-env-vars'] + + benchmark = get_benchmark(benchmark_path) + assert benchmark is not None, benchmark_path + + result_data['benchmark'] = {} + result_data['benchmark']['name'] = benchmark.name + variants = benchmark.selected_variants + if variants: + result_data['benchmark']['variants'] = variants + + bench_result = benchmark.run_one(bin_env_path, data_env_path) + + result_data['result'] = bench_result + + duration = time.time() - result_data['run']["timestamp"] + result_data['run']["duration"] = duration + + poulpe.write_data(result, result_data) + return 0 + + def get_benchmark(path_def): """get a benchmark from path applying possible variant selection on the way @@ -183,38 +218,3 @@ with open(tmp_result.name) as f: return json.load(f) - - -def run_one(bin_env_path, data_env_path, benchmark_path, result): - result_data = {} - result_data['run'] = {} - result_data['run']["timestamp"] = time.time() - - # gather info about the binary environment - bin_env_desc = poulpe.bin_env_file(bin_env_path) - bin_env_data = poulpe.get_data(bin_env_desc) - result_data['bin-env-vars'] = bin_env_data['bin-env-vars'] - - # gather info about the data environment - data_env_desc = poulpe.data_env_file(data_env_path) - data_env_data = poulpe.get_data(data_env_desc) - result_data['data-env-vars'] = data_env_data['data-env-vars'] - - benchmark = get_benchmark(benchmark_path) - assert benchmark is not None, benchmark_path - - result_data['benchmark'] = {} - result_data['benchmark']['name'] = benchmark.name - variants = benchmark.selected_variants - if variants: - result_data['benchmark']['variants'] = variants - - bench_result = benchmark.run_one(bin_env_path, data_env_path) - - result_data['result'] = bench_result - - duration = time.time() - result_data['run']["timestamp"] - result_data['run']["duration"] = duration - - poulpe.write_data(result, result_data) - return 0