Re: [PATCH v2 1/1] perf stat: Add JSON output option.

Andi Kleen
2021-08-15T14:49:54Z

[-- Attachment #1: Type: text/plain, Size: 650 bytes --]

> CSV output example:
>
> 1.20,msec,task-clock:u,1204272,100.00,0.697,CPUs utilized
> 0,,context-switches:u,1204272,100.00,0.000,/sec
> 0,,cpu-migrations:u,1204272,100.00,0.000,/sec
> 70,,page-faults:u,1204272,100.00,58.126,K/sec

The difficult part of such changes to perf stat is that it has
so many different output modes that all need to be tested.
Unfortunately the unit tests in perf test are not really
enough for it.

I have an older script (attached) that tests a lot of these outputs. It just
exercises them, you still need to check the output manually

Can you check that all these modes work correctly both
with and without json?

-Andi

[-- Attachment #2: STAT-REGR-TEST --]
[-- Type: text/plain, Size: 765 bytes --]

#!/bin/sh
# test perf stat output combinations with --metric-only
# output has to be manually verified

[ ! -d obj-perf ] && cd ..

set -x

PERF=${PERF:-./obj-perf/perf}

run() {
$PERF stat -a "$@" sleep 2
}

runprog() {
$PERF stat "$@" true
}

run
run -x,
run --per-core
run --per-socket
run -e cycles,instructions
run -dddd

# topdown
# instructions

run -I 500
run -I 500 --per-core
run -I 500 --per-socket
run -I 500 -e cycles,instructions
run -I 500 -dddd

run -I 500 -x,
run -I 500 --per-core -x,
run -I 500 --per-socket -x,
run -I 500 -e cycles,instructions -x,
run -I 500 -dddd -x,

runprog -r3
runprog -r3 -x,
$PERF stat -r3 true
$PERF stat -r3 -x, true

sleep 3 &
$PERF stat --per-thread -p $! sleep 1
$PERF stat --per-thread -t $! sleep 1