Files
linux/tools/perf/tests/shell/stat_metrics_values.sh
Ian Rogers b02e597450 perf tests: Speed up metrics checking shell tests
Optimize the execution of the metric validation and metric listing shell
test suites:

1. `stat_metrics_values.sh`:
   The Python metric validator runs the `perf bench futex hash` workload
   for each validated metric relationship. Reduce the benchmark runtime
   limit from `-r 2` (2 seconds) to `-r 1` (1 second). This cuts the
   workload duration in half while still generating sufficient PMU events
   to satisfy non-zero threshold metric validations.

2. `stat_all_metrics.sh`:
   The metric checking test runs `perf stat` sequentially across all
   433+ listed metrics. Change the default workload for system-wide runs
   from `sleep 0.01` to `true`. This avoids the 10ms sleep delay on each
   sequential metric invocation, saving over 4 seconds of total wall
   time during full test suite runs.

Assisted-by: Antigravity:gemini-3.1-pro
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2026-06-30 17:09:14 -07:00

39 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# perf metrics value validation
# SPDX-License-Identifier: GPL-2.0
shelldir=$(dirname "$0")
# shellcheck source=lib/setup_python.sh
. "${shelldir}"/lib/setup_python.sh
grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; }
# Skip if no permission to record system-wide events
if ! perf stat -a -e instructions sleep 0.01 >/dev/null 2>&1; then
echo "Skipping: no permission to record system-wide events (-a)"
exit 2
fi
pythonvalidator=$(dirname $0)/lib/perf_metric_validation.py
rulefile=$(dirname $0)/lib/perf_metric_validation_rules.json
tmpdir=$(mktemp -d /tmp/__perf_test.program.XXXXX)
workload="perf bench futex hash -r 1 -s"
# Add -debug, save data file and full rule file
echo "Launch python validation script $pythonvalidator"
echo "Output will be stored in: $tmpdir"
for cputype in /sys/bus/event_source/devices/cpu_*; do
cputype=$(basename "$cputype")
echo "Testing metrics for: $cputype"
$PYTHON $pythonvalidator -rule $rulefile -output_dir $tmpdir -wl "${workload}" \
-cputype "${cputype}"
ret=$?
rm -rf $tmpdir
if [ $ret -ne 0 ]; then
echo "Metric validation return with errors. Please check metrics reported with errors."
fi
done
exit $ret