From 3bd17527cb2618ea0bc5a79d13fafa08e20c493c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Th=C3=A9venoux?= Date: Tue, 18 Jun 2024 15:31:54 +0200 Subject: [PATCH] Add callgrind support for the performance testsuite --- testsuite/drivers/base_driver.py | 11 +++++++++++ testsuite/testsuite.py | 2 ++ 2 files changed, 13 insertions(+) diff --git a/testsuite/drivers/base_driver.py b/testsuite/drivers/base_driver.py index 8d461e9c9..5dc863594 100644 --- a/testsuite/drivers/base_driver.py +++ b/testsuite/drivers/base_driver.py @@ -318,6 +318,17 @@ def data_file(suffix: str) -> str: self.result.info["time"] = " ".join(time_list) self.result.info["memory"] = " ".join(memory_list) + elif mode == "callgrind": + result = run("valgrind", "--tool=callgrind") + # Callgrind outputs the number of executed instructions in its + # trace. Search for the line containing "Collected". + ir = "0" + for line in result.splitlines(): + if "Collected" in line: + ir = line.split()[-1] + break + self.result.info["callgrind"] = ir + elif self.env.perf_no_profile: # If we are asked for this testsuite run not to compute # profiles, skip to the next mode. diff --git a/testsuite/testsuite.py b/testsuite/testsuite.py index 891ea0627..f841fb378 100755 --- a/testsuite/testsuite.py +++ b/testsuite/testsuite.py @@ -337,6 +337,8 @@ def compute_stats(numbers_str: str, + compute_stats(entry.info["time"], float, format_time)) print(" memory: " + compute_stats(entry.info["memory"], int, format_memory)) + if "callgrind" in entry.info: + print(" callgrind's Ir: " + entry.info["callgrind"]) if __name__ == '__main__':