Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python.announce > #1914
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Andrea Stagi <stagi.andrea@gmail.com> |
| Newsgroups | comp.lang.python.announce |
| Subject | ANN lauda 1.2.0 |
| Date | Wed, 4 Nov 2015 10:17:18 +0100 |
| Lines | 65 |
| Approved | python-announce-list@python.org |
| Message-ID | <mailman.7.1446628706.16136.python-announce-list@python.org> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de hWh6fZQ8cm5qa4oOmA/c+wnp1uw9IWc4Gct7ICNEtrjg== |
| Return-Path | <stagi.andrea@gmail.com> |
| X-Original-To | python-announce-list@python.org |
| Delivered-To | python-announce-list@mail.python.org |
| X-Spam-Status | OK 0.036 |
| X-Spam-Evidence | '*H*': 0.93; '*S*': 0.00; 'subject:ANN': 0.07; 'callback': 0.09; 'url:github': 0.09; 'url:releases': 0.09; 'python': 0.10; 'def': 0.13; 'b):': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:{ 30': 0.16; 'url:tag': 0.16; '{0}': 0.16; 'portion': 0.20; 'decorator': 0.22; 'function,': 0.22; 'pass': 0.22; '8bit%:5': 0.23; 'second': 0.24; 'import': 0.24; 'module': 0.25; 'install': 0.25; "i've": 0.25; 'message- id:@mail.gmail.com': 0.27; 'function': 0.28; 'measure': 0.29; 'print': 0.30; 'code': 0.30; 'source': 0.33; 'skip:& 20': 0.35; 'received:google.com': 0.35; 'instance': 0.35; 'received:74.125.82': 0.35; 'url:in': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'entire': 0.61; 'default': 0.61; 'watch': 0.62; 'more': 0.63; 'url:0': 0.63; 'between': 0.65; 'website:': 0.65; 'url:it': 0.70; 'receive': 0.71; 'andrea': 0.84; 'decorate': 0.84; 'pip': 0.84; 'execution,': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=YyjYvd92V+F8ZrNFuFHftDAiNp9wO7emLR9lEVpn3JY=; b=YKy86Knkig9rz+HGCH3tsb6vAszlzCAJq2CECZ6wzBH0pJdYDQu2GiofdlfDgY/83/ Wo4ap7IwxnjXLmj9sxirSfHAfvhWUrjW0I2YyqnDsSNMQc3BkdbvEXcxLhdx+jTI/8+M jEAEGkEPAJLCMTGKkcXUM3me2eg6RwfPanEJ6mu3rcjuaOAnQTcQqrGzRQ7cS8q/AO/T fp0mHGV/EXunNJgQcfnG8QeOQT/zciFJoPnGw+Ev7iRsOn6wsUQgbAtjeQxBrD4qta3D 8psItmUSB0V8SnpiXc/Q8ADsvdmgI26pEKOdESAXcHSE2Tttfdkziv7bUn1LgWI95XBC Rb3g== |
| X-Received | by 10.28.92.16 with SMTP id q16mr26925305wmb.94.1446628638090; Wed, 04 Nov 2015 01:17:18 -0800 (PST) |
| X-Mailman-Approved-At | Wed, 04 Nov 2015 04:18:24 -0500 |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.20+ |
| X-BeenThere | python-announce-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | Announcement-only list for the Python programming language <python-announce-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-announce-list>, <mailto:python-announce-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-announce-list/> |
| List-Post | <mailto:python-announce-list@python.org> |
| List-Help | <mailto:python-announce-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-announce-list>, <mailto:python-announce-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python.announce:1914 |
Show key headers only | View raw
I've released lauda 1.2.0 https://github.com/astagi/lauda/releases/tag/1.2.0,
a little python module to measure time. You can install it using
pip install lauda
The source code is 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))
In the new versionm you can also get the "elapsed_time" when the stopwatch
is running, also 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
--
Andrea Stagi (@4stagi) - Develover @Nephila
Job profile: http://linkedin.com/in/andreastagi
Website: http://4spills.blogspot.it/
Github: http://github.com/astagi
Back to comp.lang.python.announce | Previous | Next | Find similar | Unroll thread
ANN lauda 1.2.0 Andrea Stagi <stagi.andrea@gmail.com> - 2015-11-04 10:17 +0100
csiph-web