2 # perf stat metrics (shadow stat) test
3 # SPDX-License-Identifier: GPL-2.0
7 # skip if system-wide mode is forbidden
8 perf stat -a true > /dev/null 2>&1 || exit 2
12 perf stat -a --no-big-num -e cycles,instructions sleep 1 2>&1 | \
13 grep -e cycles -e instructions | \
14 while read num evt hash ipc rest
16 # skip not counted events
17 if [ "$num" = "<not" ]; then
22 if [ "$evt" = "cycles" ]; then
28 if [ -z "$cyc" ]; then
32 # use printf for rounding and a leading zero
33 res=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)`
34 if [ "$ipc" != "$res" ]; then
35 echo "IPC is different: $res != $ipc ($num / $cyc)"
43 perf stat -a -A --no-big-num -e cycles,instructions sleep 1 2>&1 | \
45 while read cpu num evt hash ipc rest
47 # skip not counted events
48 if [ "$num" = "<not" ]; then
53 if [ "$evt" = "cycles" ]; then
54 results="$results $cpu:$num"
58 cyc=${results##* $cpu:}
62 if [ -z "$cyc" ]; then
66 # use printf for rounding and a leading zero
67 res=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)`
68 if [ "$ipc" != "$res" ]; then
69 echo "IPC is different for $cpu: $res != $ipc ($num / $cyc)"