perf-labs 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- perf_labs-0.2.1/LICENSE +21 -0
- perf_labs-0.2.1/PKG-INFO +218 -0
- perf_labs-0.2.1/README.md +169 -0
- perf_labs-0.2.1/bin/perf-analyze +1064 -0
- perf_labs-0.2.1/bin/perf-benchmark +1051 -0
- perf_labs-0.2.1/bin/perf-compare +361 -0
- perf_labs-0.2.1/bin/perf-optimize +389 -0
- perf_labs-0.2.1/bin/perf-plot +570 -0
- perf_labs-0.2.1/bin/perf-profile +253 -0
- perf_labs-0.2.1/bin/perf-system +484 -0
- perf_labs-0.2.1/bin/perf-view +552 -0
- perf_labs-0.2.1/bin/x86_64/perf-system-test +1340 -0
- perf_labs-0.2.1/pyproject.toml +135 -0
- perf_labs-0.2.1/setup.cfg +4 -0
- perf_labs-0.2.1/src/perf/__init__.py +52 -0
- perf_labs-0.2.1/src/perf/arch/__init__.py +58 -0
- perf_labs-0.2.1/src/perf/arch/x86_64.py +4019 -0
- perf_labs-0.2.1/src/perf/bench.py +7933 -0
- perf_labs-0.2.1/src/perf/cfg.py +355 -0
- perf_labs-0.2.1/src/perf/cmp.py +1624 -0
- perf_labs-0.2.1/src/perf/core.py +2724 -0
- perf_labs-0.2.1/src/perf/data.py +2122 -0
- perf_labs-0.2.1/src/perf/exec.py +1768 -0
- perf_labs-0.2.1/src/perf/info.py +1205 -0
- perf_labs-0.2.1/src/perf/mca.py +3477 -0
- perf_labs-0.2.1/src/perf/opt.py +2157 -0
- perf_labs-0.2.1/src/perf/plot.py +3091 -0
- perf_labs-0.2.1/src/perf/prof.py +1910 -0
- perf_labs-0.2.1/src/perf/tune.py +1741 -0
- perf_labs-0.2.1/src/perf_labs.egg-info/PKG-INFO +218 -0
- perf_labs-0.2.1/src/perf_labs.egg-info/SOURCES.txt +47 -0
- perf_labs-0.2.1/src/perf_labs.egg-info/dependency_links.txt +1 -0
- perf_labs-0.2.1/src/perf_labs.egg-info/requires.txt +30 -0
- perf_labs-0.2.1/src/perf_labs.egg-info/top_level.txt +1 -0
- perf_labs-0.2.1/tests/test_arch.py +3981 -0
- perf_labs-0.2.1/tests/test_bench.py +11157 -0
- perf_labs-0.2.1/tests/test_cfg.py +281 -0
- perf_labs-0.2.1/tests/test_cmp.py +2071 -0
- perf_labs-0.2.1/tests/test_core.py +3564 -0
- perf_labs-0.2.1/tests/test_data.py +1577 -0
- perf_labs-0.2.1/tests/test_exec.py +2272 -0
- perf_labs-0.2.1/tests/test_info.py +2164 -0
- perf_labs-0.2.1/tests/test_mca.py +3805 -0
- perf_labs-0.2.1/tests/test_opt.py +3106 -0
- perf_labs-0.2.1/tests/test_perf.py +4992 -0
- perf_labs-0.2.1/tests/test_plot.py +4163 -0
- perf_labs-0.2.1/tests/test_prof.py +2986 -0
- perf_labs-0.2.1/tests/test_tune.py +2118 -0
- perf_labs-0.2.1/tests/test_view.py +478 -0
perf_labs-0.2.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kris Jusiak <kris@jusiak.net>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
perf_labs-0.2.1/PKG-INFO
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: perf-labs
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: profile -> benchmark -> analyze -> optimize
|
|
5
|
+
Author-email: Kris Jusiak <kris@jusiak.net>
|
|
6
|
+
Maintainer-email: Kris Jusiak <kris@jusiak.net>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/perf-labs/perf
|
|
9
|
+
Project-URL: Repository, https://github.com/perf-labs/perf.git
|
|
10
|
+
Project-URL: Issues, https://github.com/perf-labs/perf/issues
|
|
11
|
+
Project-URL: Documentation, https://github.com/perf-labs/perf/blob/main/README.md
|
|
12
|
+
Keywords: profile,benchmark,analyze,optimize
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Requires-Python: >=3.12
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: angr==10.0.7
|
|
20
|
+
Requires-Dist: bitstring==4.4.0
|
|
21
|
+
Requires-Dist: capstone==5.0.9
|
|
22
|
+
Requires-Dist: pycparser==3.11
|
|
23
|
+
Requires-Dist: osaca==0.7.1
|
|
24
|
+
Requires-Dist: cxxfilt==0.3.0
|
|
25
|
+
Requires-Dist: pygraphviz==2.0.4
|
|
26
|
+
Requires-Dist: ipython==9.19.1
|
|
27
|
+
Requires-Dist: jinja2==3.1.6
|
|
28
|
+
Requires-Dist: keystone-engine==0.9.2
|
|
29
|
+
Requires-Dist: matplotlib==3.11.2
|
|
30
|
+
Requires-Dist: matplotlib-backend-sixel==0.1.0
|
|
31
|
+
Requires-Dist: mpl-ascii==1.0.1
|
|
32
|
+
Requires-Dist: numpy==2.5.5
|
|
33
|
+
Requires-Dist: orjson==3.13.0
|
|
34
|
+
Requires-Dist: pandas==3.1.1
|
|
35
|
+
Requires-Dist: py-cpuinfo==9.0.0
|
|
36
|
+
Requires-Dist: pyelftools==0.33
|
|
37
|
+
Requires-Dist: seaborn==0.13.2
|
|
38
|
+
Provides-Extra: test
|
|
39
|
+
Requires-Dist: coverage==7.17.5; extra == "test"
|
|
40
|
+
Requires-Dist: deptry==0.25.1; extra == "test"
|
|
41
|
+
Requires-Dist: ipykernel==7.4.0; extra == "test"
|
|
42
|
+
Requires-Dist: lit==23.1.6; extra == "test"
|
|
43
|
+
Requires-Dist: papermill==2.7.0; extra == "test"
|
|
44
|
+
Requires-Dist: psutil==7.2.2; extra == "test"
|
|
45
|
+
Requires-Dist: pytest==9.2.0; extra == "test"
|
|
46
|
+
Requires-Dist: pytest-cov==7.1.0; extra == "test"
|
|
47
|
+
Requires-Dist: ruff==0.17.6; extra == "test"
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
|
|
50
|
+
# perf-labs/perf
|
|
51
|
+
|
|
52
|
+
> profile → benchmark → analyze → optimize ↻
|
|
53
|
+
|
|
54
|
+
## Features
|
|
55
|
+
|
|
56
|
+
- Tune the host with custom profiles and validate against documented values.
|
|
57
|
+
- Profile binaries without recompilation, interrupts, or syscalls.
|
|
58
|
+
- Benchmark assembly, functions, and code regions using hardware performance counters.
|
|
59
|
+
- Discover symbolic inputs, configure CPU/OS state, and control benchmark conditions.
|
|
60
|
+
- Compare results with Welch t-tests, BCa bootstrap intervals, permutation tests, and multiple-comparison correction.
|
|
61
|
+
- Analyze, disassemble, and decompile machine code alongside measured data.
|
|
62
|
+
- Optimize binaries through measurement-guided passes.
|
|
63
|
+
- Visualize results in the terminal, interactive mode, or Jupyter notebooks.
|
|
64
|
+
|
|
65
|
+
## Documentation
|
|
66
|
+
|
|
67
|
+
| Name | Description |
|
|
68
|
+
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
69
|
+
| [CLI reference](bin/README.md) | Command line options, configuration |
|
|
70
|
+
| [Python API](src/README.md#api) | Architecture, synopsis |
|
|
71
|
+
| [Code Markers](lib/README.md) | Zero-instruction code (C, C++, Rust, Zig) markers |
|
|
72
|
+
| [Tutorial](TUTORIAL.md) | End-to-end walkthrough: host, benchmark, profile, analyze, compare, optimize, visualize |
|
|
73
|
+
| [Studies](studies/README.md) | Top-down Microarchitecture Analysis Method studies: [retiring](studies/x86_64/retiring), [bad-speculation](studies/x86_64/bad_speculation), [frontend-bound](studies/x86_64/frontend_bound), [backend-bound](studies/x86_64/backend_bound) |
|
|
74
|
+
| [Skills](SKILL.md) | The Human–Agent performance engineering loop |
|
|
75
|
+
| [How it works](src/README.md#how-it-works) | Symbolic exploration, data synthesis, stack/heap preparation, JIT harness, CPU control (cache/branch/...), code patching, hardware counters |
|
|
76
|
+
|
|
77
|
+
## Requirements
|
|
78
|
+
|
|
79
|
+
- [x86-64](https://github.com/perf-labs/perf/blob/main/REFERENCES.md#specifications) (requires user-space [rdpmc](https://intel.github.io/SDM/instruction/RDPMC.html) access)
|
|
80
|
+
- [Linux 6.x+](https://kernel.org) (requires [linux-perf](https://perfwiki.github.io))
|
|
81
|
+
- [Python 3.12+](https://www.python.org) (see [pyproject.toml](pyproject.toml))
|
|
82
|
+
|
|
83
|
+
## Install
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
pip install git+https://github.com/perf-labs/perf.git
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
See [Development](tests/README.md).
|
|
90
|
+
|
|
91
|
+
## Quick start
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
# info
|
|
95
|
+
perf system info
|
|
96
|
+
|
|
97
|
+
# tune
|
|
98
|
+
perf system tune # --dry-run
|
|
99
|
+
perf system status
|
|
100
|
+
|
|
101
|
+
# validate
|
|
102
|
+
perf system test # measured vs documented
|
|
103
|
+
|
|
104
|
+
# profile
|
|
105
|
+
perf profile -f hot_begin..hot_end -e cycles -- ./a.out
|
|
106
|
+
|
|
107
|
+
# benchmark
|
|
108
|
+
perf benchmark rdstc
|
|
109
|
+
perf benchmark 'imul eax, 0' -e cycles
|
|
110
|
+
perf benchmark snippet.s:label -m latency
|
|
111
|
+
perf benchmark a.out:func -m throughput -e cycles,instructions
|
|
112
|
+
perf benchmark a.out:func -e L1-dcache-load-misses,LLC-load-misses,dTLB-load-misses
|
|
113
|
+
perf benchmark a.out:func -e 'topdown-*'
|
|
114
|
+
perf benchmark a.out:0x401000..0x401020
|
|
115
|
+
perf benchmark a.out:hot_begin..hot_end # see code markers
|
|
116
|
+
perf benchmark 'mov rax, [rdi]' --data.rdi=0x42000000000 --data[0x42000000000]=123
|
|
117
|
+
perf benchmark /usr/bin/tree:main -m latency -- /path/to/folder
|
|
118
|
+
perf benchmark /usr/lib/llvm-20/lib/libc++.so:"std::__1::to_string(int)"
|
|
119
|
+
perf benchmark $(echo 'int fn(int n){ return n; }' | g++ -xc++ -c -o cc.o - && echo cc.o):fn
|
|
120
|
+
|
|
121
|
+
# compare
|
|
122
|
+
perf benchmark clang.out:func_v1 --json func_v1.json
|
|
123
|
+
perf benchmark gcc.out:func_v2 --json func_v2.json
|
|
124
|
+
perf compare --baseline func_v1 -- func_v1.json func_v2.json
|
|
125
|
+
|
|
126
|
+
# analyze
|
|
127
|
+
perf analyze a.out:func
|
|
128
|
+
perf analyze a.out:func -e assembly | llvm-mca
|
|
129
|
+
perf analyze a.out:func -e 'index,assembly,data*'
|
|
130
|
+
perf analyze a.out:func --filter 'latency > 4'
|
|
131
|
+
perf analyze a.out:func --filter '15 in `data.rdi`'
|
|
132
|
+
perf analyze a.out:func -- perf.data profile.json
|
|
133
|
+
|
|
134
|
+
# optimize
|
|
135
|
+
perf optimize a.out -- data/
|
|
136
|
+
perf optimize a.out -o b.out -- data/
|
|
137
|
+
perf optimize a.out -o b.out --opt peephole,branch -- data/
|
|
138
|
+
perf optimize a.out -o b.out --opt layout --config.layout.align=64 -- data/
|
|
139
|
+
|
|
140
|
+
# view/plot
|
|
141
|
+
perf benchmark a.out:func | perf view
|
|
142
|
+
perf benchmark a.out:func -e cycles,instructions | perf view -e instructions/cycles
|
|
143
|
+
perf benchmark a.out:func | perf plot
|
|
144
|
+
perf analyze a.out:func | perf plot
|
|
145
|
+
perf plot -e instructions/cycles -- perf.data
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
See [CLI reference](bin/README.md).
|
|
149
|
+
|
|
150
|
+
```py
|
|
151
|
+
import perf
|
|
152
|
+
|
|
153
|
+
# info
|
|
154
|
+
print(perf.system.info())
|
|
155
|
+
|
|
156
|
+
# tune
|
|
157
|
+
perf.system.tune()
|
|
158
|
+
print(perf.system.status())
|
|
159
|
+
|
|
160
|
+
# validate
|
|
161
|
+
print(perf.system.test())
|
|
162
|
+
|
|
163
|
+
# profile
|
|
164
|
+
df = perf.profile(["./a.out"], event=["cycles"], filter=["hot_begin..hot_end"])
|
|
165
|
+
|
|
166
|
+
# benchmark
|
|
167
|
+
df = perf.benchmark("rdtsc")
|
|
168
|
+
df = perf.benchmark("imul eax, 0", event=["cycles"])
|
|
169
|
+
df = perf.benchmark("snippet.s:label", mode=["latency"])
|
|
170
|
+
df = perf.benchmark("a.out:func", event=["cycles", "instructions"])
|
|
171
|
+
df = perf.benchmark("a.out:func", event=["L1-dcache-load-misses"])
|
|
172
|
+
df = perf.benchmark("a.out:func", event=["topdown-*"])
|
|
173
|
+
df = perf.benchmark("a.out:0x401000..0x401020")
|
|
174
|
+
df = perf.benchmark("a.out:hot_begin..hot_end")
|
|
175
|
+
df = perf.benchmark("mov rax, [rdi]", data={"rdi": 0x42000000000, "0x42000000000": 123})
|
|
176
|
+
df = perf.benchmark("/usr/bin/tree:main", mode=["latency"])
|
|
177
|
+
df = perf.benchmark("/usr/lib/llvm-20/lib/libc++.so:std::__1::to_string(int)")
|
|
178
|
+
|
|
179
|
+
# compare
|
|
180
|
+
v1 = perf.benchmark("clang.out:func_v1")
|
|
181
|
+
v2 = perf.benchmark("gcc.out:func_v2")
|
|
182
|
+
print(perf.compare(pd.concat([v1, v2]), baseline="func_v1"))
|
|
183
|
+
|
|
184
|
+
# analyze
|
|
185
|
+
df = perf.analyze("a.out:func")
|
|
186
|
+
df = perf.analyze("a.out:func", event=["assembly"])
|
|
187
|
+
df = perf.analyze("a.out:func", event=["index", "assembly", "data*"])
|
|
188
|
+
df = perf.analyze("a.out:func", filter="latency > 4")
|
|
189
|
+
df = perf.analyze("a.out:func", filter="15 in `data.rdi`")
|
|
190
|
+
df = perf.analyze("a.out:func", data=[perf.data.parse(["perf.data"])])
|
|
191
|
+
|
|
192
|
+
# optimize
|
|
193
|
+
df = perf.optimize("a.out", data=["data/"])
|
|
194
|
+
df = perf.optimize("a.out", data=["data/"], opt=["peephole", "branch"])
|
|
195
|
+
|
|
196
|
+
# view/plot
|
|
197
|
+
df = perf.benchmark("a.out:func", event=["cycles", "instructions"])
|
|
198
|
+
print((df["instructions"] / df["cycles"])
|
|
199
|
+
perf.plot(perf.benchmark("a.out:func"))
|
|
200
|
+
perf.plot(perf.analyze("a.out:func"))
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
See [Python API](src/README.md#api).
|
|
204
|
+
|
|
205
|
+
## Citation
|
|
206
|
+
|
|
207
|
+
```bibtex
|
|
208
|
+
@software{perflabs2026perf,
|
|
209
|
+
author = {{perf-labs}},
|
|
210
|
+
title = {{perf}: Profile, Benchmark, Analyze, Optimize},
|
|
211
|
+
year = {2026},
|
|
212
|
+
url = {https://github.com/perf-labs/perf}
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## References
|
|
217
|
+
|
|
218
|
+
See [REFERENCES.md](REFERENCES.md).
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# perf-labs/perf
|
|
2
|
+
|
|
3
|
+
> profile → benchmark → analyze → optimize ↻
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Tune the host with custom profiles and validate against documented values.
|
|
8
|
+
- Profile binaries without recompilation, interrupts, or syscalls.
|
|
9
|
+
- Benchmark assembly, functions, and code regions using hardware performance counters.
|
|
10
|
+
- Discover symbolic inputs, configure CPU/OS state, and control benchmark conditions.
|
|
11
|
+
- Compare results with Welch t-tests, BCa bootstrap intervals, permutation tests, and multiple-comparison correction.
|
|
12
|
+
- Analyze, disassemble, and decompile machine code alongside measured data.
|
|
13
|
+
- Optimize binaries through measurement-guided passes.
|
|
14
|
+
- Visualize results in the terminal, interactive mode, or Jupyter notebooks.
|
|
15
|
+
|
|
16
|
+
## Documentation
|
|
17
|
+
|
|
18
|
+
| Name | Description |
|
|
19
|
+
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
20
|
+
| [CLI reference](bin/README.md) | Command line options, configuration |
|
|
21
|
+
| [Python API](src/README.md#api) | Architecture, synopsis |
|
|
22
|
+
| [Code Markers](lib/README.md) | Zero-instruction code (C, C++, Rust, Zig) markers |
|
|
23
|
+
| [Tutorial](TUTORIAL.md) | End-to-end walkthrough: host, benchmark, profile, analyze, compare, optimize, visualize |
|
|
24
|
+
| [Studies](studies/README.md) | Top-down Microarchitecture Analysis Method studies: [retiring](studies/x86_64/retiring), [bad-speculation](studies/x86_64/bad_speculation), [frontend-bound](studies/x86_64/frontend_bound), [backend-bound](studies/x86_64/backend_bound) |
|
|
25
|
+
| [Skills](SKILL.md) | The Human–Agent performance engineering loop |
|
|
26
|
+
| [How it works](src/README.md#how-it-works) | Symbolic exploration, data synthesis, stack/heap preparation, JIT harness, CPU control (cache/branch/...), code patching, hardware counters |
|
|
27
|
+
|
|
28
|
+
## Requirements
|
|
29
|
+
|
|
30
|
+
- [x86-64](https://github.com/perf-labs/perf/blob/main/REFERENCES.md#specifications) (requires user-space [rdpmc](https://intel.github.io/SDM/instruction/RDPMC.html) access)
|
|
31
|
+
- [Linux 6.x+](https://kernel.org) (requires [linux-perf](https://perfwiki.github.io))
|
|
32
|
+
- [Python 3.12+](https://www.python.org) (see [pyproject.toml](pyproject.toml))
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
pip install git+https://github.com/perf-labs/perf.git
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
See [Development](tests/README.md).
|
|
41
|
+
|
|
42
|
+
## Quick start
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
# info
|
|
46
|
+
perf system info
|
|
47
|
+
|
|
48
|
+
# tune
|
|
49
|
+
perf system tune # --dry-run
|
|
50
|
+
perf system status
|
|
51
|
+
|
|
52
|
+
# validate
|
|
53
|
+
perf system test # measured vs documented
|
|
54
|
+
|
|
55
|
+
# profile
|
|
56
|
+
perf profile -f hot_begin..hot_end -e cycles -- ./a.out
|
|
57
|
+
|
|
58
|
+
# benchmark
|
|
59
|
+
perf benchmark rdstc
|
|
60
|
+
perf benchmark 'imul eax, 0' -e cycles
|
|
61
|
+
perf benchmark snippet.s:label -m latency
|
|
62
|
+
perf benchmark a.out:func -m throughput -e cycles,instructions
|
|
63
|
+
perf benchmark a.out:func -e L1-dcache-load-misses,LLC-load-misses,dTLB-load-misses
|
|
64
|
+
perf benchmark a.out:func -e 'topdown-*'
|
|
65
|
+
perf benchmark a.out:0x401000..0x401020
|
|
66
|
+
perf benchmark a.out:hot_begin..hot_end # see code markers
|
|
67
|
+
perf benchmark 'mov rax, [rdi]' --data.rdi=0x42000000000 --data[0x42000000000]=123
|
|
68
|
+
perf benchmark /usr/bin/tree:main -m latency -- /path/to/folder
|
|
69
|
+
perf benchmark /usr/lib/llvm-20/lib/libc++.so:"std::__1::to_string(int)"
|
|
70
|
+
perf benchmark $(echo 'int fn(int n){ return n; }' | g++ -xc++ -c -o cc.o - && echo cc.o):fn
|
|
71
|
+
|
|
72
|
+
# compare
|
|
73
|
+
perf benchmark clang.out:func_v1 --json func_v1.json
|
|
74
|
+
perf benchmark gcc.out:func_v2 --json func_v2.json
|
|
75
|
+
perf compare --baseline func_v1 -- func_v1.json func_v2.json
|
|
76
|
+
|
|
77
|
+
# analyze
|
|
78
|
+
perf analyze a.out:func
|
|
79
|
+
perf analyze a.out:func -e assembly | llvm-mca
|
|
80
|
+
perf analyze a.out:func -e 'index,assembly,data*'
|
|
81
|
+
perf analyze a.out:func --filter 'latency > 4'
|
|
82
|
+
perf analyze a.out:func --filter '15 in `data.rdi`'
|
|
83
|
+
perf analyze a.out:func -- perf.data profile.json
|
|
84
|
+
|
|
85
|
+
# optimize
|
|
86
|
+
perf optimize a.out -- data/
|
|
87
|
+
perf optimize a.out -o b.out -- data/
|
|
88
|
+
perf optimize a.out -o b.out --opt peephole,branch -- data/
|
|
89
|
+
perf optimize a.out -o b.out --opt layout --config.layout.align=64 -- data/
|
|
90
|
+
|
|
91
|
+
# view/plot
|
|
92
|
+
perf benchmark a.out:func | perf view
|
|
93
|
+
perf benchmark a.out:func -e cycles,instructions | perf view -e instructions/cycles
|
|
94
|
+
perf benchmark a.out:func | perf plot
|
|
95
|
+
perf analyze a.out:func | perf plot
|
|
96
|
+
perf plot -e instructions/cycles -- perf.data
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
See [CLI reference](bin/README.md).
|
|
100
|
+
|
|
101
|
+
```py
|
|
102
|
+
import perf
|
|
103
|
+
|
|
104
|
+
# info
|
|
105
|
+
print(perf.system.info())
|
|
106
|
+
|
|
107
|
+
# tune
|
|
108
|
+
perf.system.tune()
|
|
109
|
+
print(perf.system.status())
|
|
110
|
+
|
|
111
|
+
# validate
|
|
112
|
+
print(perf.system.test())
|
|
113
|
+
|
|
114
|
+
# profile
|
|
115
|
+
df = perf.profile(["./a.out"], event=["cycles"], filter=["hot_begin..hot_end"])
|
|
116
|
+
|
|
117
|
+
# benchmark
|
|
118
|
+
df = perf.benchmark("rdtsc")
|
|
119
|
+
df = perf.benchmark("imul eax, 0", event=["cycles"])
|
|
120
|
+
df = perf.benchmark("snippet.s:label", mode=["latency"])
|
|
121
|
+
df = perf.benchmark("a.out:func", event=["cycles", "instructions"])
|
|
122
|
+
df = perf.benchmark("a.out:func", event=["L1-dcache-load-misses"])
|
|
123
|
+
df = perf.benchmark("a.out:func", event=["topdown-*"])
|
|
124
|
+
df = perf.benchmark("a.out:0x401000..0x401020")
|
|
125
|
+
df = perf.benchmark("a.out:hot_begin..hot_end")
|
|
126
|
+
df = perf.benchmark("mov rax, [rdi]", data={"rdi": 0x42000000000, "0x42000000000": 123})
|
|
127
|
+
df = perf.benchmark("/usr/bin/tree:main", mode=["latency"])
|
|
128
|
+
df = perf.benchmark("/usr/lib/llvm-20/lib/libc++.so:std::__1::to_string(int)")
|
|
129
|
+
|
|
130
|
+
# compare
|
|
131
|
+
v1 = perf.benchmark("clang.out:func_v1")
|
|
132
|
+
v2 = perf.benchmark("gcc.out:func_v2")
|
|
133
|
+
print(perf.compare(pd.concat([v1, v2]), baseline="func_v1"))
|
|
134
|
+
|
|
135
|
+
# analyze
|
|
136
|
+
df = perf.analyze("a.out:func")
|
|
137
|
+
df = perf.analyze("a.out:func", event=["assembly"])
|
|
138
|
+
df = perf.analyze("a.out:func", event=["index", "assembly", "data*"])
|
|
139
|
+
df = perf.analyze("a.out:func", filter="latency > 4")
|
|
140
|
+
df = perf.analyze("a.out:func", filter="15 in `data.rdi`")
|
|
141
|
+
df = perf.analyze("a.out:func", data=[perf.data.parse(["perf.data"])])
|
|
142
|
+
|
|
143
|
+
# optimize
|
|
144
|
+
df = perf.optimize("a.out", data=["data/"])
|
|
145
|
+
df = perf.optimize("a.out", data=["data/"], opt=["peephole", "branch"])
|
|
146
|
+
|
|
147
|
+
# view/plot
|
|
148
|
+
df = perf.benchmark("a.out:func", event=["cycles", "instructions"])
|
|
149
|
+
print((df["instructions"] / df["cycles"])
|
|
150
|
+
perf.plot(perf.benchmark("a.out:func"))
|
|
151
|
+
perf.plot(perf.analyze("a.out:func"))
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
See [Python API](src/README.md#api).
|
|
155
|
+
|
|
156
|
+
## Citation
|
|
157
|
+
|
|
158
|
+
```bibtex
|
|
159
|
+
@software{perflabs2026perf,
|
|
160
|
+
author = {{perf-labs}},
|
|
161
|
+
title = {{perf}: Profile, Benchmark, Analyze, Optimize},
|
|
162
|
+
year = {2026},
|
|
163
|
+
url = {https://github.com/perf-labs/perf}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## References
|
|
168
|
+
|
|
169
|
+
See [REFERENCES.md](REFERENCES.md).
|