2 # perf stat metrics (shadow stat) test
3 # SPDX-License-Identifier: GPL-2.0
9 # skip if system-wide mode is forbidden
10 perf stat
-a true
> /dev
/null
2>&1 ||
exit 2
12 # skip if on hybrid platform
13 perf stat
-a -e cycles
sleep 1 2>&1 |
grep -e cpu_core
&& exit 2
17 perf stat
-a --no-big-num -e cycles
,instructions
sleep 1 2>&1 | \
18 grep -e cycles
-e instructions | \
19 while read num evt _ ipc rest
21 # skip not counted events
22 if [ "$num" = "<not" ]; then
27 if [ "$evt" = "cycles" ]; then
33 if [ -z "$cyc" ]; then
37 # use printf for rounding and a leading zero
38 res
=`echo $num $cyc | awk '{printf "%.2f", $1 / $2}'`
39 if [ "$ipc" != "$res" ]; then
40 # check the difference from the real result for FP imperfections
41 diff=`echo $ipc $res $THRESHOLD | \
42 awk '{x = ($1 - $2) < 0 ? ($2 - $1) : ($1 - $2); print (x > $3)}'`
44 if [ $diff -eq 1 ]; then
45 echo "IPC is different: $res != $ipc ($num / $cyc)"
49 echo "Warning: Difference of IPC is under the threshold"
56 perf stat
-a -A --no-big-num -e cycles
,instructions
sleep 1 2>&1 | \
58 while read cpu num evt _ ipc rest
60 # skip not counted events
61 if [ "$num" = "<not" ]; then
66 if [ "$evt" = "cycles" ]; then
67 results
="$results $cpu:$num"
71 cyc
=${results##* $cpu:}
75 if [ -z "$cyc" ]; then
79 # use printf for rounding and a leading zero
80 res
=`echo $num $cyc | awk '{printf "%.2f", $1 / $2}'`
81 if [ "$ipc" != "$res" ]; then
82 # check difference from the real result for FP imperfections
83 diff=`echo $ipc $res $THRESHOLD | \
84 awk '{x = ($1 - $2) < 0 ? ($2 - $1) : ($1 - $2); print (x > $3)}'`
86 if [ $diff -eq 1 ]; then
87 echo "IPC is different: $res != $ipc ($num / $cyc)"
91 echo "Warning: Difference of IPC is under the threshold"