Giter VIP home page Giter VIP logo

perfcounters's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.