Skip to main content

A package for timing python code

Project description

Time It!

pip install time-it to install

  • Python Decorator for timing functions. Its fast, and fun!
from time_it import time_def

@time_def
def time_max(A):
  return max(A)
  
time_max([1,4,2,5,3,3]) # prints execution time of time_max function and returns max value

With a logger

# setup logger
logger = logging.getLogger("gen")
logger.setLevel(logging.DEBUG)
stdh = logging.StreamHandler(sys.stdout)
stdh.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
stdh.setFormatter(formatter)
logger.addHandler(stdh)

# add decorator to function
@time_def(log_name="gen")
def time_with_log(A):
    return max(A)

time_with_log([1,4,2,5,3,3]) 

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

time_it-3.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

time_it-3-py3-none-any.whl (3.6 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