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.1.tar.gz
(1.8 kB
view hashes)
Built Distribution
Close
Hashes for chronic-0.1.1.macosx-10.8-x86_64.exe
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59c56af47f31a7fbb4c2ccac47281953241e7815f464f25a7a40b8391ade2e82 |
|
MD5 | 7566fff3f7d494506b190a8a2934e772 |
|
BLAKE2b-256 | f26e2724d85c9f156ff530e7013ca24f078b276c026558cea8e180853639ce1e |