Skip to main content

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/

Project details


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

runtime_stats-0.1.2-py3-none-any.whl (3.7 kB view hashes)

Uploaded Python 3

runtime_stats-0.1.2-py2-none-any.whl (3.7 kB view hashes)

Uploaded Python 2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page