]> git.lttng.org Git - lttng-ci.git/commitdiff
benchmark: Add option to control the taskset used for the command
authorKienan Stewart <kstewart@efficios.com>
Wed, 22 Jan 2025 17:02:22 +0000 (12:02 -0500)
committerKienan Stewart <kstewart@efficios.com>
Wed, 22 Jan 2025 18:20:25 +0000 (13:20 -0500)
Change-Id: Ibf13d6ff0f74adc298cd2129c8960da2ba64f5e8
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
scripts/babeltrace-benchmark/time.py [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index c7f7505..0c414f1
@@ -106,7 +106,7 @@ def save(path, results):
         json.dump(results, out, sort_keys=True, indent=4)
 
 
-def run(command, iteration, output, stdout, stderr):
+def run(command, iteration, output, stdout, stderr, taskset=""):
     """
     Run the command throught /usr/bin/time n iterations and parse each result.
     """
@@ -117,6 +117,8 @@ def run(command, iteration, output, stdout, stderr):
         time_stdout.close()
         with open(stdout, "a+") as out, open(stderr, "a+") as err:
             cmd = "/usr/bin/time -v --output='{}' {}".format(time_stdout.name, command)
+            if taskset:
+                cmd = "taskset -c {} {}".format(taskset, cmd)
             ret = subprocess.run(cmd, shell=True, stdout=out, stderr=err)
             if ret.returncode != 0:
                 print("Iteration: {}, Command failed: {}".format(str(i), cmd))
@@ -176,9 +178,21 @@ def main():
         default=os.path.join(os.getcwd(), "stderr.out"),
         help="Where to append the stderr of each command (default: $CWD/stderr.out)",
     )
+    parser.add_argument(
+        "--taskset",
+        default="",
+        help="Define a CPU taskset for the test command. See `man taskset`'s `-c` argument",
+    )
 
     args = parser.parse_args()
-    run(args.command, args.iteration, args.output, args.stdout, args.stderr)
+    run(
+        args.command,
+        args.iteration,
+        args.output,
+        args.stdout,
+        args.stderr,
+        args.taskset,
+    )
 
 
 if __name__ == "__main__":
This page took 0.026548 seconds and 4 git commands to generate.