Skip to main content

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

Metadata

Release files for lauda 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lauda 1.2.0
File Size Uploaded
lauda-1.2.0.tar.gz 2.0 kB Details

Release files / lauda-1.2.0.tar.gz

Download URL lauda-1.2.0.tar.gz
Size 2.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cdaf83ecaa1ef4680ebac630f203087b8badc238370c135a19374457c0f9b74d
BLAKE2b-256 checksum
How to use checksums
11d6b33a3a015ab640aa3a0ea46cebf0fb1028e3413b195aac92286f994069f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.2.0 This release

1 release file

1.1.0

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page