Python decorator function to track runtime stats on function calls
Project description
# Runtime Stats for Functions
Python decorator function to track runtime stats on function calls
# Example
```
@runtime_stats()
def self_mult(n):
sleep(0.2)
return n*n
print(self_mult(10)) # => 100
print(self_mult(7)) # => 49
print(self_mult.get_func_runtime_stats()) # => {'total_time': 401.668, 'avg': 200.834, 'func_uid': 4302206808, 'func_name': 'self_mult', 'min': 200.445, 'max': 201.223, 'total_calls': 2}
```
# Usage
Decorate a function with `@runtime_stats()` to keep track of that function's runtime (min, max, avg, total_calls, and total_time)
# Compatibility
Tested compatible with Py2.7 and Py3, but this code is provided as is with no warranty or guarantee, implied or explicit.
# More Information
Please see my blog post here: http://garrens.com/blog/2016/10/21/runtime-stats-for-functions-python-decorator/
Python decorator function to track runtime stats on function calls
# Example
```
@runtime_stats()
def self_mult(n):
sleep(0.2)
return n*n
print(self_mult(10)) # => 100
print(self_mult(7)) # => 49
print(self_mult.get_func_runtime_stats()) # => {'total_time': 401.668, 'avg': 200.834, 'func_uid': 4302206808, 'func_name': 'self_mult', 'min': 200.445, 'max': 201.223, 'total_calls': 2}
```
# Usage
Decorate a function with `@runtime_stats()` to keep track of that function's runtime (min, max, avg, total_calls, and total_time)
# Compatibility
Tested compatible with Py2.7 and Py3, but this code is provided as is with no warranty or guarantee, implied or explicit.
# More Information
Please see my blog post here: http://garrens.com/blog/2016/10/21/runtime-stats-for-functions-python-decorator/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
Close
Hashes for runtime_stats-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c91e78ed9a4efd254330f0e259ba465d1a7485c9002972da3e47acae0abf5b31 |
|
MD5 | c63aef4f4b0568ad9c47b2e772dcab67 |
|
BLAKE2b-256 | 5dcfc0168580e76ff533b5df59d754435caa90931666d1bc08af3e9a97aa34c2 |
Close
Hashes for runtime_stats-0.1.1-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73d7c392fc92e25ef35985b50afd68b1b9377295fc5913fb759745c1cf9cbe81 |
|
MD5 | 79ac7a5e5242dc1bb474d7a1e3a21571 |
|
BLAKE2b-256 | b04280c6279461fe133ad7851f7fd8cc10e4b4b93b3486eafb02e5475b2d52e8 |