A small Python class to quickly measure the time taken while executing a block of indented lines
linetimer: A small Python class to measure the time taken by indented lines.
linetimer is a small Python class to quickly measure the time taken by a block of indented lines
To install the library, simply type in
pip install linetimer in your terminal.
The basic usage is:
from linetimer import CodeTimer with CodeTimer(): line_to_measure() another_line() # etc...
Which will show the following after the indented line(s) finishes executing:
Code block took: x.xxx ms
You can also name the code blocks you want to measure:
with CodeTimer('loop 1'): for i in range(100000): pass with CodeTimer('loop 2'): for i in range(100000): pass Code block 'loop 1' took: 4.991 ms Code block 'loop 2' took: 3.666 ms
And nest them:
with CodeTimer('Outer'): for i in range(100000): pass with CodeTimer('Inner'): for i in range(100000): pass for i in range(100000): pass Code block 'Inner' took: 2.382 ms Code block 'Outer' took: 10.466 ms
If you like this package, upvote it on StackOverflow.
If you encounter a problem, create an issue on Github.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size linetimer-0.1.0-py2-none-any.whl (3.3 kB)||File type Wheel||Python version py2||Upload date||Hashes View|
|Filename, size linetimer-0.1.0-py3-none-any.whl (2.5 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size linetimer-0.1.0.tar.gz (2.1 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for linetimer-0.1.0-py2-none-any.whl
Hashes for linetimer-0.1.0-py3-none-any.whl