Skip to main content

Cirron measures how many CPU instructions and system calls a piece of Python code executes.

Project description

Cirron

Cirron measures a piece of Python code and report back several performance counters: CPU instruction count, branch misses, page faults and time spent measuring. It uses the Linux perf events interface or @ibireme's KPC demo on OSX.

It can also trace syscalls using strace, Linux only!

Prerequisites

  • Linux with perf events support / Apple ARM OSX
  • C++
  • Python 3.x

Installation

Python

pip install cirron

The wrapper automatically compiles the C++ library (cirronlib.cpp) on first use.

Usage

Performance Counters

$ sudo python
>>> from cirron import Collector
>>> 
>>> # Start collecting performance metrics
>>> with Collector() as collector:
>>>     # Your code here
>>>     print("Hello")
>>> 
>>> # Retrieve the metrics
>>> print(collector.counters)
Counter(time_enabled_ns=144185, instruction_count=19434, branch_misses=440, page_faults=0)

Syscalls

$ sudo python
>>> from cirron import Tracer, to_tef

>>> with Tracer() as tracer:
>>>     # Your code here
>>>     print("Hello")
>>> 
>>> # Retrieve the trace
>>> print(tracer.trace)
>>> [Syscall(name='write', args='1, "Hello\\n", 6', retval='6', duration='0.000043', timestamp='1720333364.368337', pid='2270837')]
>>> 
>>> # Save the trace for ingesting to Perfetto
>>> open("/tmp/trace", "w").write(to_tef(tracer.trace))

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

Cirron-0.3.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

Cirron-0.3-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file Cirron-0.3.tar.gz.

File metadata

  • Download URL: Cirron-0.3.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.7

File hashes

Hashes for Cirron-0.3.tar.gz
Algorithm Hash digest
SHA256 72656a62bf2900a89f2598f8a361cb7354b0530eb0ef9300a0ab00a422e4e3ba
MD5 55048c36a4f09fde40af0a72c75c90d2
BLAKE2b-256 4d084686e59b8f12ab9fa2dc01e5480b5ab74a36aae5c257422e237af52e5de1

See more details on using hashes here.

File details

Details for the file Cirron-0.3-py3-none-any.whl.

File metadata

  • Download URL: Cirron-0.3-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.7

File hashes

Hashes for Cirron-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2002b5550b0cdbae191ad6c0b603f3dc80410daac65edd6ae87fff22ee3bbece
MD5 59f621695c6cb24ac2927c2e5ac1a779
BLAKE2b-256 5548c933764cab93f07a150229c0c591075ed80a68ae6e8357e7c57f6771620c

See more details on using hashes here.

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