Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/acdha/python-performance-tools
Tools for tracking and displaying the performance of Python programs during normal operation
https://github.com/acdha/python-performance-tools
Last synced: about 1 month ago
JSON representation
Tools for tracking and displaying the performance of Python programs during normal operation
- Host: GitHub
- URL: https://github.com/acdha/python-performance-tools
- Owner: acdha
- License: other
- Created: 2013-07-26T16:43:24.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-10-28T20:19:19.000Z (about 11 years ago)
- Last Synced: 2024-11-22T08:51:53.973Z (about 2 months ago)
- Language: Python
- Homepage:
- Size: 125 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.txt
- License: LICENSE.txt
Awesome Lists containing this project
README
========================
Python Performance Tools
========================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.