The branch main has been updated by gnn: URL: https://cgit.FreeBSD.org/src/commit/?id=4a1b69ade6b5e8665dfb4d0cb683854705192a68
commit 4a1b69ade6b5e8665dfb4d0cb683854705192a68 Author: George V. Neville-Neil <[email protected]> AuthorDate: 2026-01-05 12:30:22 +0000 Commit: George V. Neville-Neil <[email protected]> CommitDate: 2026-01-05 12:30:22 +0000 Start adding an exercise mode for programs under test. In exercise mode we collect data for every available counter on a program and keep all of that in a directory in /tmp. --- tools/test/hwpmc/pmctest.py | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/tools/test/hwpmc/pmctest.py b/tools/test/hwpmc/pmctest.py index bda2f3500d7d..f54541aeea1e 100755 --- a/tools/test/hwpmc/pmctest.py +++ b/tools/test/hwpmc/pmctest.py @@ -23,6 +23,7 @@ import subprocess from subprocess import PIPE import argparse +import tempfile def gather_counters(): """Run program and return output as array of lines.""" @@ -39,6 +40,7 @@ def main(): parser = argparse.ArgumentParser(description='Exercise a program under hwpmc') parser.add_argument('--program', type=str, required=True, help='target program') parser.add_argument('--wait', action='store_true', help='Wait after each counter.') + parser.add_argument('--exercise', action='store_true', help='Exercise the program being studied using sampling counters.') args = parser.parse_args() @@ -48,19 +50,32 @@ def main(): print("no counters found") sys.exit() + if args.exercise == True: + tmpdir = tempfile.mkdtemp() + print("Exercising program ", args.program, " storing results data in ", tmpdir) + for counter in counters: if counter in notcounter: continue - p = subprocess.Popen(["pmcstat", "-p", counter, args.program], + if args.exercise == True: + p = subprocess.Popen(["pmcstat", + "-O", tmpdir + "/" + args.program + "-" + counter + ".pmc", + "-g", + "-P", counter, args.program], + text=True, stderr=PIPE) + result = p.communicate()[1] + print(result) + else: + p = subprocess.Popen(["pmcstat", "-p", counter, args.program], text=True, stderr=PIPE) - result = p.communicate()[1] - print(result) - if (args.wait == True): - try: - value = input("Waitin for you to press ENTER") - except EOFError: - sys.exit() - + result = p.communicate()[1] + print(result) + if (args.wait == True): + try: + value = input("Waitin for you to press ENTER") + except EOFError: + sys.exit() + # The canonical way to make a python module into a script. # Remove if unnecessary.
