Skip to content

Commit 63bfbeb

Browse files
authored
Merge pull request #55 from redhat-performance/feat/selected-benchmarks
Add `--benchmarks` flag to limit what benchmarks pyperformance runs
2 parents 6afb07d + cc53018 commit 63bfbeb

1 file changed

Lines changed: 35 additions & 2 deletions

File tree

pyperf/pyperf_run

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ install_pip=0
2323
PYTHON_VERSION=""
2424
PYPERF_VERSION="1.11.0"
2525
copy_dirs=""
26+
benchmarks="all"
2627

2728
base_dir=$(dirname $(realpath $0))
2829
#
@@ -46,10 +47,31 @@ usage()
4647
echo "--pyperf_version <version number>: Version of pyperf to run, default is $PYPERF_VERSION."
4748
echo "--python_exec_path: Python to set via alternatives"
4849
echo "--python_pkgs: comma seprated list of python packages to install"
50+
echo "--pyperf_benchmarks: Comma separated list of pyperformance benchmarks to run. Default is to run all tests."
4951
source test_tools/general_setup --usage
5052
exit 1
5153
}
5254

55+
verify_benchmark_names()
56+
{
57+
benchmark_file=$(mktemp pyperf_benchmarks.XXXXX)
58+
$python_exec -m pyperformance list | head -n -2 | tail -n +2 | sed -e 's/- //g' > $benchmark_file
59+
invalid_benchmarks=""
60+
for benchmark in $(echo $benchmarks | tr ',' ' '); do
61+
grep $benchmark $benchmark_file > /dev/null
62+
63+
if [[ $? -ne 0 ]]; then
64+
invalid_benchmarks="$benchmark $invalid_benchmarks"
65+
fi
66+
done
67+
68+
rm -f $benchmark_file
69+
70+
if [[ -n "$invalid_benchmarks" ]]; then
71+
exit_out "Error: Could not find the following benchmarks $invalid_benchmarks" 1
72+
fi
73+
}
74+
5375
install_tools()
5476
{
5577
show_usage=0
@@ -221,7 +243,7 @@ ${curdir}/test_tools/gather_data ${curdir}
221243
if [ ! -f "/tmp/pyperf.out" ]; then
222244
command="${0} $@"
223245
echo $command
224-
$command &> /tmp/pyperf.out
246+
$command 2>&1 | tee /tmp/pyperf.out
225247
rtc=$?
226248
if [ -f /tmp/pyperf.out ]; then
227249
echo =================================
@@ -255,6 +277,7 @@ ARGUMENT_LIST=(
255277
"pyperf_version"
256278
"python_exec"
257279
"python_pkgs"
280+
"pyperf_benchmarks"
258281
)
259282

260283
NO_ARGUMENTS=(
@@ -291,6 +314,10 @@ while [[ $# -gt 0 ]]; do
291314
install_pip=1
292315
shift 1
293316
;;
317+
--pyperf_benchmarks)
318+
benchmarks=$2
319+
shift 2
320+
;;
294321
--usage)
295322
usage $0
296323
;;
@@ -351,7 +378,13 @@ if [[ $to_use_pcp -eq 1 ]]; then
351378
copy_dirs="$pcp_dir"
352379
fi
353380

354-
$python_exec -m pyperformance run --output ${pyresults}.json
381+
pyperf_flags=""
382+
if [[ "$benchmarks" != "all" ]]; then
383+
verify_benchmark_names
384+
pyperf_flags="-b $benchmarks"
385+
fi
386+
387+
$python_exec -m pyperformance run --output ${pyresults}.json $pyperf_flags
355388
if [ $? -ne 0 ]; then
356389
exit_out "Failed: $python_exec -m pyperformance run --output ${pyresults}.json" 1
357390
fi

0 commit comments

Comments
 (0)