scenario 5: fix perf annotate command
This commit is contained in:
parent
51ab2ed553
commit
4f680b6a2d
@ -72,22 +72,35 @@ With debug symbols, you can see exactly which lines are hot:
|
||||
|
||||
```bash
|
||||
perf record ./withdebug 500 5000
|
||||
perf annotate compute_inner
|
||||
perf annotate --stdio -l compute_inner
|
||||
```
|
||||
|
||||
This shows the source code with cycle counts per line!
|
||||
The `-l` flag shows a summary of hot source lines at the top:
|
||||
|
||||
```
|
||||
│ double compute_inner(double x, int iterations) {
|
||||
│ double result = x;
|
||||
1.23 │ for (int i = 0; i < iterations; i++) {
|
||||
45.67 │ result = sin(result) * cos(result) + sqrt(fabs(result));
|
||||
23.45 │ result = result * 1.0001 + 0.0001;
|
||||
│ }
|
||||
│ return result;
|
||||
│ }
|
||||
Sorted summary for file .../withdebug
|
||||
----------------------------------------------
|
||||
72.75 program.c:29
|
||||
27.25 program.c:28
|
||||
```
|
||||
|
||||
This tells you line 29 (`result = result * 1.0001 + 0.0001`) consumed ~73% of cycles!
|
||||
|
||||
Below the summary, you see interleaved source and assembly:
|
||||
|
||||
```
|
||||
Percent | Source code & Disassembly of withdebug
|
||||
--------------------------------------------------
|
||||
: 9 double compute_inner(double x, int iterations) {
|
||||
: 10 double result = x;
|
||||
27.25 : 130f: addsd %xmm0,%xmm1 // program.c:28
|
||||
27.67 : 1313: mulsd ... // program.c:29
|
||||
```
|
||||
|
||||
**Note on line numbers**: The left margin (9, 10, etc.) shows objdump output
|
||||
line numbers, NOT source file lines. The actual source lines are shown in the
|
||||
summary and in `// program.c:XX` comments on assembly lines.
|
||||
|
||||
## Exercise 5: Understanding Symbol Tables
|
||||
|
||||
```bash
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user