Skip to main content

Easily measure Python function performance

Project description

Measurer

Easily measure Python function performance

Install

$ pip install measurer

Usage

import measure

@measure.time(repeats=100, copy=False, gc_off=True)
def a():
    pass  # Your logic here
print(a())  # 6.700000000005313e-06

def b():
    pass  # Your logic here
print(measure.time(b, repeats=100, copy=False, gc_off=True)())  # 6.199999999997874e-06

Goal

Currently, this module contains only one decorator measuring function execution time. The goal was to make performance evaluation extremely easy for non-experienced programmers, who wants to check how much resources their programs/solutions take. As a subject for future development, other types of measurers could be implemented (e.g. memory, recursive function calls etc.)

Details

Why not "timeit" ?

Timeit is not suitable for function calls with arguments. Thus, one has to wrap a tested function with another function (without arguments) and evaluate redundant function calls (which sometimes causes big overhead).

We still perform redundant calls...

Yes. Ideally, we have to analyze syntactic tree and create some sort of "inline" method call. However, this is a hobby module, so we don't push towards ideal implementation.

Why do we dump parameters with Pickle?

Packages like "msgpack" or "marshal" show comparable performance (and time to time they are faster), but the difference is not significant. So we use pickle, cause it's a built-in package (we try to leave the module simple).

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

measurer-1.0.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

measurer-1.0.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file measurer-1.0.0.tar.gz.

File metadata

  • Download URL: measurer-1.0.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.7

File hashes

Hashes for measurer-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ad54e32210375d12b5b19e257febbec03187f1b1e7e22c181b0daa6653458af3
MD5 d782863db0c1e66d2e5e6d6b76864b2d
BLAKE2b-256 21bdc02073beca80fc9f30b052d8e2d399e33fdd459454f29993c68f0f9f6b02

See more details on using hashes here.

File details

Details for the file measurer-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: measurer-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.7

File hashes

Hashes for measurer-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f0eeb9068291f6c597a9a7146a905c9e9488aa85ab8fd5462b0cec5fbdb78cf6
MD5 82b3cc5c76880f1579afd29e1ab19512
BLAKE2b-256 66088c11dc4cedf8513be43b177484085050780b78e0842a65e1be65eff65e41

See more details on using hashes here.

Supported by

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