Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Utilities for measuring application performance

Project Description

Simple utilities to make it easier to track performance of Python programs under normal operations

Context Managers

DisplayElapsed

This context manager makes it easy to display console-oriented start/end messages with end-user tolerable formatting.

Usage:

with DisplayElapsed("{now} uploading {filename} (original: {original})\n",
                    "{now} uploaded {filename} in {elapsed:.1f} seconds",
                    filename=remote_path, original=local_path):
    upload_filename(…)

Notes:

  • DisplayElapsed takes one positional argument: message. The message is formatted using str.format with the values {now} and {elapsed} provided automatically. All other keyword arguments provided to DisplayElapsed will be available during formatting.
  • If message contains {{now}} it will be replaced with the current timestamp
  • If message does not contain {{now}} it will be prepended unless include_timestamp=False
  • If postamble is not specified, it will default to " ({elapsed:.1f} seconds)"
  • If output is not specified, it will default to sys.stdout
  • If output_on_error is not True, the normal postamble display will be suppressed when an exception occurs
  • By default, a newline will not be emitted after the opening message so the message and postamble will be displayed on a single line. output will be flushed, if supported, to provide immediate feedback. Provide a message which ends in \n if you want multi-line output.
Release History

Release History

This version
History Node

0.3

History Node

0.2

History Node

0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
performance_tools-0.3.tar.gz (6.7 kB) Copy SHA256 Checksum SHA256 Source Oct 28, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS 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