Simple stopwatch to easily print the elapsed time of a set of operations
Project description
Computational Stopwatch
Simple stopwatch to easily print the elapsed time of a set of operations. It's a minimalistic library, but it is very useful in many real cases.
Usage
The easiest way to use this tool is in conjunction with the with python statement.
>> from computational_stopwatch import Stopwatch
>>
>> with Stopwatch():
>> time.sleep(3) # <- simulates a long computation
Elapsed time 0:00:03.003106
anything within the scope of the with statement will count against the elapsed time. An optional task name to be printed along the elapsed time (e.g. for better identification in a log) can be set in the constructor.
Alternatively, the class can be directly instantiated and the print function explicitly called.
>> sw = Stopwatch()
>> time.sleep(3)
>> sw.print_elapsed_time()
Elapsed time 0:00:03.003280
The start time can be reset with the reset_time function and the get_elapsed_time method returns the unformatted elapsed time, which is useful for numerical comparisons.
Versions History
v1.0.1
- minor fixes
v1.0.0
- first reelease
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for computational_stopwatch-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e3f0cabd729a378ae592a1595ed3f0acebd2bea1ae20cd61f6520ad0ad75805 |
|
MD5 | 22abd85f7b30b522f5cc3be122fc5562 |
|
BLAKE2b-256 | 830cc044e6a43ac668203d91cc471de3ae44fe5c383152acbcd3adab475322fc |
Hashes for computational_stopwatch-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bb4a4448ce0e69dd44b324724dc033da68850ce652e2bf0d505ad402f9190b7 |
|
MD5 | 5f4ef60bf3dde56f1f6b2c50306d0c67 |
|
BLAKE2b-256 | c2e6a769f9bad83b4b76143215ff3175b08d4f98ab8e2978579c8d3ec65b53da |