py-perf-event 0.2.0

Creator: bradpython12

Last updated:

Add to Cart

Description:

pyperfevent 0.2.0

Python interface to CPU counters on Linux
Or, a minimal wrapper around the py-perf-event2 Rust crate, using the Linux perf subsystem.
To install: pip install py-perf-event
Example
from py_perf_event import measure, Hardware

[instructions1] = measure([Hardware.INSTRUCTIONS], sum, range(1_000_000))
print(instructions1)
[instructions2] = measure([Hardware.INSTRUCTIONS], sum, range(10_000_000))
print(instructions2)
assert instructions1 > 1_000_000
assert 7 < (instructions2 / instructions1) < 15

Other usage
See the tests for more examples.
Until more docs are available, you can use the underlying Rust libraries docs to see what fields are available on the Hardware and CacheId/CacheOp/CacheResult classes.
Changelog

0.2: Exposed Raw events.
0.1: Initial, very minimal release.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.