Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python.announce > #1741
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.datemas.de!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2b.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| 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.091 |
| X-Spam-Evidence | '*H*': 0.82; '*S*': 0.00; 'subject:ANN': 0.07; 'callback': 0.09; 'url:github': 0.09; 'python': 0.11; 'def': 0.14; 'b):': 0.16; 'skip:{ 30': 0.16; 'portion': 0.20; 'decorator': 0.22; 'function,': 0.22; 'pass': 0.22; '8bit%:5': 0.23; 'module': 0.23; "i've": 0.24; 'import': 0.24; 'install': 0.25; 'message- id:@mail.gmail.com': 0.28; 'measure': 0.29; 'function': 0.30; 'print': 0.31; 'source': 0.31; 'code': 0.31; 'received:google.com': 0.34; 'instance': 0.35; 'created': 0.36; 'to:addr:python.org': 0.39; 'your': 0.60; 'entire': 0.61; 'default': 0.61; 'watch': 0.62; 'more': 0.62; 'website:': 0.65; '\xc2\xa0\xc2\xa0': 0.66; 'url:it': 0.67; '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=LHbA+6Xom5Ievw7XnoE0C76pswxjRaus7chH4/Bph70=; b=zsadPGxCly/Vu/WBEUcX83j3CevcuzRvlORuSvRZ9dXzo7DZrcaxN+TrCQtynzs79q nq+W2EJKm0SUPYqqwwnSDxCzaIXhqOoE05O15nnsNbi4kH0K7Rxa8yea7Uy4TJGEgAT4 lKCKnC1bfv990uF3qfndaP/KR2tOH+JFsFCsMOJwb7mIB5i6PhSQMr1dlA+WHHD56T0y GdYNGSU3EdqQunBEhEVWU4vjXvK76aJva922m6gP3BQ8LdI1aVjRkGFiIlxpqqORor+D 1CHWKz/+9w4Y5ECvlh0PUgoZO9oPE/Blj+V/mjmr3KnWOqg2wSV2uZ+rb+B/3+vPyuMm cucA== |
| MIME-Version | 1.0 |
| X-Received | by 10.180.228.6 with SMTP id se6mr39831208wic.33.1434439579396; Tue, 16 Jun 2015 00:26:19 -0700 (PDT) |
| Date | Tue, 16 Jun 2015 09:26:19 +0200 |
| Subject | ANN lauda 1.0.0 |
| From | Andrea Stagi <stagi.andrea@gmail.com> |
| To | python-announce-list@python.org |
| X-Mailman-Approved-At | Tue, 16 Jun 2015 09:31:36 +0200 |
| Content-Type | text/plain; charset=UTF-8 |
| 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> |
| Approved | python-announce-list@python.org |
| Newsgroups | comp.lang.python.announce |
| Message-ID | <mailman.502.1434439897.13271.python-announce-list@python.org> (permalink) |
| Lines | 47 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1434439897 news.xs4all.nl 2885 [2001:888:2000:d::a6]:56683 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python.announce:1741 |
Show key headers only | View raw
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
Back to comp.lang.python.announce | Previous | Next | Find similar | Unroll thread
ANN lauda 1.0.0 Andrea Stagi <stagi.andrea@gmail.com> - 2015-06-16 09:26 +0200
csiph-web