This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Python elapsed time utilities.

The main interface to this package is an ElapsedTimer class. This class will use the highest resolution timer available to Python depending on the OS, either time.time() or time.clock(). Its purpose is easily to measure and print the duration of a task, and is normally meant to be used as a context manager.

Basic example:

>>> with ElapsedTimer('say hello'):
...     print 'hi there!'
hi there!
13.113 µs: say hello

ElapsedTimer

The constructor for ElapsedTimer takes an optional string describing the operation being performed. It also optionally accepts a file object to change where the resulting duration message will be printed. The output file defaults to sys.stdout.

The constructor can also take a logger instance and log level via the optional logger and loglevel keyword parameters. If a logger is provided, it takes precedence over a file object and the duration message will be output via the logger. The log level defaults to DEBUG.

You can control an ElapsedTimer instance directly instead of using it as a context manager. It has start() and stop() methods. The stop() method will not print the duration for you like exiting a context manager instance does.

There is an elapsed property that returns the elapsed time since start() was called or the context manager entered. A timedelta property is also available that returns the elapsed time as a datetime.timedelta object instead of a float, though note that this class this only has microsecond resolution.

There is a module-level enable variable that acts as a global enable switch for all printing of results by ElapsedTimer. It defaults to True.

Timeout

Another class in the module is Timeout. It adds a few methods to make it easy to check for timeouts. You can use this class as a context manager. The constructor takes the same parameters as for ElapsedTimer, except for a new first param of the timeout in seconds.

There are two methods to check the timeout, check() and check_and_raise(). The former compares the elapsed time against the timeout and returned True if a timeout occurred. The latter will raise TimeoutError if a timeout happens. You can use the timed_out property to as another way to check, equivalent to calling check().

License

This package is licensed under the BSD three-clause license. See the LICENSE file for details.

Copyright © 2014-2016 Chris Reed.

Release History

Release History

0.4

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
elapsedtimer-0.4-py2.py3-none-any.whl (6.7 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Oct 18, 2016
elapsedtimer-0.4.tar.gz (5.3 kB) Copy SHA256 Checksum SHA256 Source Oct 18, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting