Is there a way by which I can specify perf
tool to give stats of first n instructions for an executable? Thanks
Asked
Active
Viewed 59 times
0

emotionull
- 595
- 2
- 8
- 24
-
Be careful about "first instructions", they could not be the one you may think. Remember that before entering the main function, thousands of instructions are executed (more than 400.000 here). What is your goal counting instructions like that? I would like to understand, in order to provide a more accurate help if I can. – amigadev Nov 09 '14 at 08:35
1 Answers
0
Try this
1. perf record -e instructions -c no_of_instrucitons executable_path
2. sudo perf report -D -i perf.data > test
3. vi test
4. Search for "PERF_RECORD_SAMPLE" string
5. This string should be repeated the number of times equal to the samples taken throughout the execution of the binary
6. If you remove the samples other than the first one and rename test to perf.data you should have the results after "perf report"
P.S. This is all approximate values. And make sure the perf.data header and footer should be intact when you remove samples

Milind Dumbare
- 3,104
- 2
- 19
- 32