Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kludex/simpletiming
Time your functions in a smart way! ~ Highly Inspired by codetiming :tada:
https://github.com/kludex/simpletiming
Last synced: 26 days ago
JSON representation
Time your functions in a smart way! ~ Highly Inspired by codetiming :tada:
- Host: GitHub
- URL: https://github.com/kludex/simpletiming
- Owner: Kludex
- License: mit
- Created: 2021-01-08T00:06:42.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-01-08T01:39:23.000Z (almost 4 years ago)
- Last Synced: 2024-10-07T18:21:32.651Z (about 1 month ago)
- Language: Python
- Homepage:
- Size: 23.4 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Simple Timing
## Installation
``` bash
pip install simpletiming
```## Usage
### As decorator
``` Python
from simpletiming import Timer
from time import sleep@Timer(name="Potato")
def potato():
sleep(1)potato()
# Elapsed time: 1.0011 seconds
```### As object
``` Python
timer = Timer()timer.start()
sleep(1)
timer.stop()# Elapsed time 1.0011 seconds
```### As context manager
``` Python
with Timer(message="Elapsed time: {minutes:0.4f} minutes"):
sleep(1)# Elapsed time: 0.0167 minutes
```### On all class methods
``` Python
@Timer(name="MyClass", message="{name}: {seconds:0.4f} seconds")
class MyClass:
def potato(self):
sleep(1)obj = MyClass()
obj.potato()# MyClass: 1.0011 seconds
```## License
This project is licensed under the terms of the MIT license.