0001
0002
0003
0004
0005 set -e
0006
0007
0008 compare_number()
0009 {
0010 first_num=$1
0011 second_num=$2
0012
0013
0014 upper=$(expr $first_num + $first_num / 10 )
0015
0016 lower=$(expr $first_num - $first_num / 10 )
0017
0018 if [ $second_num -gt $upper ] || [ $second_num -lt $lower ]; then
0019 echo "The difference between $first_num and $second_num are greater than 10%."
0020 exit 1
0021 fi
0022 }
0023
0024
0025 if ! perf stat --bpf-counters true > /dev/null 2>&1; then
0026 if [ "$1" = "-v" ]; then
0027 echo "Skipping: --bpf-counters not supported"
0028 perf --no-pager stat --bpf-counters true || true
0029 fi
0030 exit 2
0031 fi
0032
0033 base_cycles=$(perf stat --no-big-num -e cycles -- perf bench sched messaging -g 1 -l 100 -t 2>&1 | awk '/cycles/ {print $1}')
0034 if [ "$base_cycles" == "<not" ]; then
0035 echo "Skipping: cycles event not counted"
0036 exit 2
0037 fi
0038 bpf_cycles=$(perf stat --no-big-num --bpf-counters -e cycles -- perf bench sched messaging -g 1 -l 100 -t 2>&1 | awk '/cycles/ {print $1}')
0039 if [ "$bpf_cycles" == "<not" ]; then
0040 echo "Failed: cycles not counted with --bpf-counters"
0041 exit 1
0042 fi
0043
0044 compare_number $base_cycles $bpf_cycles
0045 exit 0