Skip to content

Commit cc53018

Browse files
committed
feat: Add benchmark name checking
When running using `--pyperf_benchmarks`, it will now check against `pyperformance list` to ensure that an invalid benchmark was not provided. Current behaviour is to exit when at least 1 benchmark is not valid, but the script will output all invalid benchmarks.
1 parent 30528df commit cc53018

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

pyperf/pyperf_run

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,26 @@ usage()
5252
exit 1
5353
}
5454

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+
5575
install_tools()
5676
{
5777
show_usage=0
@@ -223,7 +243,7 @@ ${curdir}/test_tools/gather_data ${curdir}
223243
if [ ! -f "/tmp/pyperf.out" ]; then
224244
command="${0} $@"
225245
echo $command
226-
$command &> /tmp/pyperf.out
246+
$command 2>&1 | tee /tmp/pyperf.out
227247
rtc=$?
228248
if [ -f /tmp/pyperf.out ]; then
229249
echo =================================
@@ -360,6 +380,7 @@ fi
360380

361381
pyperf_flags=""
362382
if [[ "$benchmarks" != "all" ]]; then
383+
verify_benchmark_names
363384
pyperf_flags="-b $benchmarks"
364385
fi
365386

0 commit comments

Comments
 (0)