Skip to main content

PerfCounters

Coverage Status license

Easily add performance counters to your python code.

PerfCounter is a thoroughly tested library that make it easy to add counters to any python code to measure intermediate timings and values. Its various reporting mechanisms (pretty print, json, html, latex, markdown... ) makes it easy to analyze and report performance measurement regardless of your workflow.

Perfcounters natively support two kind of counters:

  • TimeCounters() that are used to track timings.
  • ValueCounters() thatr used if you want to track values.

For each counter you can track intermediate values using the lap() API if needed.

Basic usage

Here is a short example that demonstrate how to track time. Tracking values looks very similarly.

import random
from perfcounters import TimeCounters

cnts = TimeCounters()  # init the counter collection.

cnts.start('random')  # start a timing counter called random.
for x in range(100000):
    int(random.random())
cnts.stop('random')  # stop the random counter

cnts.start('randint')  # start a timing counter called randint.
for x in range(1000000):
    random.randint(0, 1)
cnts.stop('randint')  # stop the randint counter.

cnts.report(rounding=5) # report print all counter values in a nicely formated table.

For more advanced usage take look at the demo jupyter notebook.

Installation

The easiest way to install perfcounters is via pip:

pip install --user -U perfcounters

Metadata

Release files for perfcounters 3.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for perfcounters 3.0.1
File Size Uploaded
perfcounters-3.0.1.tar.gz 10.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for perfcounters 3.0.1
File Interpreter ABI Platform
perfcounters-3.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 21.3 kB

Release files / perfcounters-3.0.1.tar.gz

Download URL perfcounters-3.0.1.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
93463d8a9c3abab104feac8e52450ca3902eb6d0ba57f02c231b3b9b4eca975c
BLAKE2b-256 checksum
How to use checksums
75be6ebc30483773a649b6a7647b84c7979d6660309de8573f579a5b021e1ee6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.8

Release files / perfcounters-3.0.1-py3-none-any.whl

Download URL perfcounters-3.0.1-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
656b9c739f5dd7595f5b187e93cfcd91958f2afe750ec5c7c1db77f5d960f20d
BLAKE2b-256 checksum
How to use checksums
8c05b389556c41169d02024109fbde8574d36f6c1dccd85070e05ae067d4bef1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.8

Release history Release notifications | RSS feed

This release

3.0.1 This release

2 release files

3.0.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page