Skip to content

CodeBlanco/python-module-time_it

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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]) 

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages