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
14 perf stat
-a --no-big-num -e cycles
,instructions
sleep 1 2>&1 | \
15 grep -e cycles
-e instructions | \
16 while read num evt
hash ipc rest
18 # skip not counted events
19 if [[ $num == "<not" ]]; then
24 if [[ $evt == "cycles" ]]; then
30 if [[ -z $cyc ]]; then
34 # use printf for rounding and a leading zero
35 local res
=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)`
36 if [[ $ipc != $res ]]; then
37 echo "IPC is different: $res != $ipc ($num / $cyc)"
47 perf stat
-a -A --no-big-num -e cycles
,instructions
sleep 1 2>&1 | \
49 while read cpu num evt
hash ipc rest
51 # skip not counted events
52 if [[ $num == "<not" ]]; then
57 if [[ $evt == "cycles" ]]; then
63 local cyc
=${results[$cpu]}
64 if [[ -z $cyc ]]; then
68 # use printf for rounding and a leading zero
69 local res
=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)`
70 if [[ $ipc != $res ]]; then
71 echo "IPC is different for $cpu: $res != $ipc ($num / $cyc)"