Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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:

Awesome Lists containing this project

README

        


Simple Timing




Latest Commit






Package version



## 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.