December 11, 2025

I am currently building a hobby project: pyk/bench, a microbenchmarking library for Zig. My goal is to make it fast and accurate. To measure performance properly, looking at wall clock time is not enough. I need to know what the CPU is actually doing.

I want to measure CPU cycles, instruction counts and cache misses. On Linux the kernel provides a system call for this named perf_event_open. It is very powerful but the API is raw and not easy to use safely.

Understanding perf_event_open

The perf_event_open system call creates a file descriptor that allows measuring performance information. You fill out a perf_event_attr struct with the config you want, suc…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help