GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - astagi/lauda: :watch: A very simple python module for measuring time.

BranchesTags
Open more actions menu

Latest commit

 

History

41 Commits
41 Commits

Folders and files

NameName
Last commit message
Last commit date
lauda
lauda
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
AUTHORS.txt
AUTHORS.txt
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
demo.py
demo.py
 
 
requirements-test.txt
requirements-test.txt
 
 
requirements.txt
requirements.txt
 
 
setup.cfg
setup.cfg
 
 
setup.py
setup.py
 
 
tox.ini
tox.ini
 
 

Repository files navigation

Lauda

Build Status Codecov.io Status Latest Version Supported Python versions License Downloads

A very simple python module for measuring time.

Install

pip install lauda

Usage

You can use lauda StopWatch to measure the time spent in a portion of code

from lauda import StopWatch

watch = StopWatch()
watch.start()
for i in range(10000000):
    pass
watch.stop()
print ('Time spent in range {0}'.format(watch.elapsed_time))

You can also get the elapsed_time when the stopwatch is running

You can call checkpoint function if you want to set a checkpoint and get the time spent between the last checkpoint:

from lauda import StopWatch

watch = StopWatch()
watch.start()
for i in range(10000000):
    pass
check_time = watch.checkpoint()
print ('Time spent in first range: {0} sec.'.format(check_time))
for i in range(10000000):
    pass
check_time = watch.checkpoint()
print ('Time spent in second range: {0} sec.'.format(check_time))

If you want to measure an entire function execution, you can decorate it using the stopwatch decorator

from lauda import stopwatch

@stopwatch
def awesome_mul(a, b):
    return a * b

By default stopwatch decorator will print the time spent inside the decorated function, if you want more control you can pass to your decorator a callback that will receive a StopWatch instance and the decorated function.

from lauda import stopwatch

def stopwatch_sum_cb(watch, function):
    print ('Time spent {0}'.format(watch.elapsed_time))

@stopwatch(callback=stopwatch_sum_cb)
def awesome_sum(a, b):
    return a + b

If you want to measure a block of code, you can use the stopwatchcm context manager

from lauda import stopwatchcm

with stopwatchcm():
    c = a * b

By default stopwatchcm context manager will print the time spent inside the context manager body, if you want more control you can pass to your context manager a callback that will receive a StopWatch instance.

from lauda import stopwatchcm

def stopwatch_sum_cb(watch):
    print ('Time spent {0}'.format(watch.elapsed_time))

with stopwatchcm(callback=stopwatch_sum_cb):
    c = a + b

About

⌚ A very simple python module for measuring time.

Resources

Readme
MIT license
Activity

Stars

25 stars

Watchers

2 watching

Forks

4 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.