sabhiram / py-timer

A super simple way to measure code execution time in python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

py-timer

A super simple way to measure code execution time in python.

Install

sudo python setup.py install

Usage

import time
from pytimer import PyTimer

if __name__ == "__main__":
    with PyTimer("Task A"):
        time.sleep(1)

This will generate something like:

Task A took 1.003875

The timer can also be disabled by setting the enable flag in the constructor to False like so:

with PyTimer("Task A", enabled=False):
    time.sleep(1)

Feel free to include this as a class in your script / application, or install this using the above install method.

Example

See file: example/example.py.

About

A super simple way to measure code execution time in python

License:MIT License


Languages

Language:Python 94.3%Language:Makefile 5.7%