Newer
Older
#!/usr/bin/env python
import argparse
import os
import subprocess
import sys
def shell_exec(command, env=None):
# Simulate bash script printing the commands it runs
print("+ %s" % command)
process = subprocess.Popen(command, shell=False, env=env)
retcode = process.wait()
if retcode:
raise subprocess.CalledProcessError(retcode, command)
def main(args):
parser = argparse.ArgumentParser()
parser.add_argument(
"target", nargs="?", help="the changesets to run benchmarks against"
)
"--force",
help="force running all selected benchmarks for the selected changesets",
action="store_const",
const=True,
default=False,
)
parser.add_argument(
"-q",
"--quiet",
help="make asv run quieter",
action="store_const",
const=True,
default=False,
)
args, unknown = parser.parse_known_args(args)
# Process target
if args.target is None:
target = "1.9:: and tagged()"
else:
target = args.target
# Prepare all files
shell_exec(["./lib/before-check.sh"])
run_command = ["asv", "run"]
# Force ASV to spawn a separate process per test, so it kills childrens
# when the test timeout. In the fork_server mode (the default), it kill
# the process group at the very end only so some perf* commands might
# still be running while other tests started
run_command.extend(["--launch-method", "spawn"])
# Run ASV on specific cores for stability
# Examples, `2,3`, `0-4`, `0`
cpu_affinity = os.environ.get("ASV_CPU_AFFINITY")
if cpu_affinity:
run_command.extend(["--cpu-affinity", cpu_affinity])
asv_flags = ["--verbose", "--show-stderr"]
else:
asv_flags = []
if not args.force:
asv_flags.append("--skip-existing-successful")
run_command.extend(asv_flags)
run_command.append(target)