wallClockProfiler
wallClockProfiler copied to clipboard
`perf` instructions incomplete
To measure wall clock time, perf -e task-clock can be used:
perf record --call-graph dwarf,16000 -e task-clock ./testProf
99.92% 0.19% testProf testProf [.] main
|
--99.73%--main
readRandFileValue
|
|--96.41%--__GI_fseek (inlined)
| |
| --95.45%--_IO_new_file_seekoff (inlined)
| |
| |--46.41%--__GI___libc_read (inlined)
| |
| --45.47%--__lseek64 (inlined)
|
--2.41%--getRandomBoundedInt
|
--1.15%--rand
|
--1.05%--__random
|
--0.73%--__random_r
Hey, that's very cool.
I guess perf works to do this after all.
I will leave this here for others to see. I may update the docs at some point in the future, but it's not a high priority right now.
Actually, where is this documented? Not in the man page:
https://man7.org/linux/man-pages/man1/perf.1.html
Maybe it's a newer feature? Even the -e switch isn't mentioned there.
-e is documented in the more specific pages like:
https://man7.org/linux/man-pages/man1/perf-record.1.html https://man7.org/linux/man-pages/man1/perf-stat.1.html#EXAMPLES
It takes a bit of digging though, in particular to figure out what task-clock actually means: https://stackoverflow.com/questions/23965363/linux-perf-events-cpu-clock-and-task-clock-what-is-the-difference
task-clock does`t work for me. Shows only task execution time, not wait of any kind. Quick check:
$ perf stat -e task-clock sleep 1 ↑
Performance counter stats for 'sleep 1':
0,53 msec task-clock # 0,001 CPUs utilized
1,001286900 seconds time elapsed
0,001180000 seconds user
0,000000000 seconds sys
no matter how many seconds to wait.
It's just pure luck that __GI_fseek execution time above anything too in report above. But it does`t really count wait time.