ANN lauda 1.0.0

Andrea Stagi stagi.andrea at gmail.com
Tue Jun 16 09:26:19 CEST 2015


I've created lauda, a little python module to measure time. You can install
it with

    pip install lauda

you can find the source code on Github: https://github.com/astagi/lauda

You can use lauda StopWatch to measure 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))

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


-- 
Andrea Stagi (@4stagi) - Develover @Nephila
Job profile: http://linkedin.com/in/andreastagi
Website: http://4spills.blogspot.it/
Github: http://github.com/astagi


More information about the Python-announce-list mailing list