Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to sample per core or per thread with `perf stat`?

I want to profiling per core or per thread (event driven or time driven). But perf aggregates all values together.

For example, if I want to profiling core 0~3 every 1 second with perf:

perf stat -I 1000 -a -c 0-3 -e instructions,cycles command

There will be instructions and cycles of all 4 cores every second.

What I really want is instructions and cycles of each core per second.

Is there other tools that can implement the function?

Or can I modify source code of perf to implement it by myself? Is the aggregration coded in user space or kernel space?

BTW: perf record can sample per thread but it cannot profiling in real-time.

like image 279
oleotiger Avatar asked Oct 17 '25 15:10

oleotiger


1 Answers

It's possible! You have to add -A or --no-aggr per pef-stat man page.

perf stat -C 0-3 --no-aggr -e instructions,cycles command
like image 52
Santiago MC Avatar answered Oct 20 '25 06:10

Santiago MC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!