Half profiler, half timer, 100% gangsta
Project description
Chronic - Python Profiler
=========================
Chronic is halfway between a simple timer and a profiler. It does not track every call like a profiler does. You must specify what levels you want to time. But it keeps the hierarchy of your timings intact.
```python
import chronic
from pprint import pprint
@chronic.time
def time_one():
pass
@chronic.time
def time_two():
with chronic.Timer('block2'):
print chronic.stack()
# ['time_two', 'block2']
pprint(chronic.timings())
# prints local view of timings
# {'block2': {'average_elapsed': 1.0967254638671875e-05,
# 'count': 1,
# 'total_elapsed': 1.0967254638671875e-05}}
with chronic.Timer('block1'):
time_one()
pprint(chronic.timings())
def print_done(timings, stack):
print stack
pprint(timings)
chronic.post_timing.connect(print_done)
time_one()
# []
# {'average_elapsed': 9.5367431640625e-07,
# 'count': 1,
# 'total_elapsed': 9.5367431640625e-07}
chronic.post_timing.disconnect(print_done)
time_two()
# ['time_two', 'block2']
# {'block2': {'average_elapsed': 5.9604644775390625e-06,
# 'count': 1,
# 'total_elapsed': 5.9604644775390625e-06}}
```
This software is licensed under the MIT license. See the details in the file called LICENSE.
=========================
Chronic is halfway between a simple timer and a profiler. It does not track every call like a profiler does. You must specify what levels you want to time. But it keeps the hierarchy of your timings intact.
```python
import chronic
from pprint import pprint
@chronic.time
def time_one():
pass
@chronic.time
def time_two():
with chronic.Timer('block2'):
print chronic.stack()
# ['time_two', 'block2']
pprint(chronic.timings())
# prints local view of timings
# {'block2': {'average_elapsed': 1.0967254638671875e-05,
# 'count': 1,
# 'total_elapsed': 1.0967254638671875e-05}}
with chronic.Timer('block1'):
time_one()
pprint(chronic.timings())
def print_done(timings, stack):
print stack
pprint(timings)
chronic.post_timing.connect(print_done)
time_one()
# []
# {'average_elapsed': 9.5367431640625e-07,
# 'count': 1,
# 'total_elapsed': 9.5367431640625e-07}
chronic.post_timing.disconnect(print_done)
time_two()
# ['time_two', 'block2']
# {'block2': {'average_elapsed': 5.9604644775390625e-06,
# 'count': 1,
# 'total_elapsed': 5.9604644775390625e-06}}
```
This software is licensed under the MIT license. See the details in the file called LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
chronic-0.1.tar.gz
(1.8 kB
view hashes)
Built Distribution
Close
Hashes for chronic-0.1.macosx-10.8-x86_64.exe
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3105025ee11d8c6fe3b96f95df0ca248616af95df7ab48a04346b10f9756e724 |
|
MD5 | 0db982413d5c9b1590dd9c6dfa7fdb8d |
|
BLAKE2b-256 | 1ec1f5866bb37f601dc44c2dff077d15be3c53659e5bb86ac2abdaa738d83900 |