https://github.com/johnberroa/codetimer
https://github.com/johnberroa/codetimer
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/johnberroa/codetimer
- Owner: johnberroa
- License: mit
- Created: 2019-01-06T19:17:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-06T19:41:28.000Z (over 7 years ago)
- Last Synced: 2024-12-28T05:43:02.897Z (over 1 year ago)
- Language: Python
- Size: 3.91 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Code Timer
This lightweight timer can time any section of code desired, and makes converting run times to minutes/hours a lot easier than having to fiddle with your ```time.time() - start_time``` output.
## Usage
Printing the timer while running or when stopped will return the current run time in seconds, minutes, and hours.
```
timer = Timer("Repeating Calculation")
timer.start()
for i in range(2):
function.apply()
print(timer)
timer.stop()
print(timer)
```
Output will be:
```
Timer 'Repeating Calculation' still running: Time elapsed 'Repeating Calculation': 6s (.1m | 0h)
Timer 'Repeating Calculation' still running: Time elapsed 'Repeating Calculation': 12s (.2m | 0h)
Time elapsed 'Repeating Calculation': 7s (.1m | 0h)
```