Skip to main content

No project description provided

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_perf_event-0.2.0.tar.gz (8.0 kB view hashes)

Uploaded Source

Built Distributions

py_perf_event-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ x86-64

py_perf_event-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARM64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page