Skip to main content

Simple profiling decorator

Project description

PyPI version

A simple profiling decorator:

In [1]: from profiled import profiled, Profiler

In [2]: @profiled
   ...: def get_answer():
   ...:     return 42
   ...:

In [3]: profiler = Profiler()

In [4]: with profiler:
   ...:     for i in range(100000): get_answer()
   ...:

In [5]: profiler.compute_stats()
Out[5]:
{'get_answer': {'avg': 2.2763967514038087e-07,
  'max': 0.00016736984252929688,
  'min': 0.0,
  'num': 100000,
  'std': 6.953436521202228e-07,
  'tot': 0.022763967514038086}}

The decorator also works with class methods. That’s about it.

Install with pip install profiled.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

profiled-2.0.0.tar.gz (2.4 kB view hashes)

Uploaded Source

Built Distribution

profiled-2.0.0-py3-none-any.whl (2.9 kB view hashes)

Uploaded Python 3

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