|
|
|
|
|
by hcineb
1686 days ago
|
|
I built a Python code metering library to track the execution time of bits of Python code. You can create clocks anywhere as so: from ticktock import tick
clock = tick()
# do some work
clock.tock()
Any encountered clock is registered and its timing measured, aggregated and printed periodically.The output consists in one line per clock: [some_file.py:4-6] 43us count=21
[lib.py:44-68] 500ms count=5034
(continuously updated as clocks are stepped through more times)I find this convenient for quick-and-dirty Python profiling, especially for code that runs many times over. I am happy to take any feedback or issues. There are a couple of known bugs (tqdm progress bars for a start), but it mostly does the job! |
|