File: perf.md

package info (click to toggle)
firefox 143.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,617,328 kB
  • sloc: cpp: 7,478,492; javascript: 6,417,157; ansic: 3,720,058; python: 1,396,372; xml: 627,523; asm: 438,677; java: 186,156; sh: 63,477; makefile: 19,171; objc: 13,059; perl: 12,983; yacc: 4,583; cs: 3,846; pascal: 3,405; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (57 lines) | stat: -rw-r--r-- 1,610 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Perf

`perf` is a powerful system-wide instrumentation service that is part of
Linux. This article discusses how it can be relevant to power profiling.

**Note**: The [power profiling
overview](power_profiling_overview.md) is
worth reading at this point if you haven't already. It may make parts
of this document easier to understand.

## Energy estimates

`perf` can access the Intel RAPL energy estimates. The following example
shows how to invoke it for this purpose.

```
sudo perf stat -a -r 1 \
    -e "power/energy-pkg/" \
    -e "power/energy-cores/" \
    -e "power/energy-gpu/" \
    -e "power/energy-ram/" \
    <command>
```

The `-a` is necessary; it means \"all cores\", and without it all the
measurements will be zero. The `-r 1` means `<command>` is executed
once; higher values can be used to get variations.

The output will look like the following.

```
Performance counter stats for 'system wide':

   51.58 Joules power/energy-pkg/     [100.00%]
   14.80 Joules power/energy-cores/   [100.00%]
    9.93 Joules power/energy-gpu/     [100.00%]
   27.38 Joules power/energy-ram/     [100.00%]

5.003049064 seconds time elapsed
```

It's not clear from the output, but the following relationship holds.

```
energy-pkg >= energy-cores + energy-gpu
```

The measurement is in Joules, which is usually less useful than Watts.

For these reasons
[rapl](tools_power_rapl.md) is usually a
better tool for measuring power consumption on Linux.

## Wakeups {#Wakeups}

`perf` can also be used to do [high-context profiling of
wakeups](http://robertovitillo.com/2014/02/04/idle-wakeups-are-evil/).