Wallclock

A simple stack-based performance logger
Download

Wallclock Ranking & Summary

Advertisement

  • Rating:
  • License:
  • MIT/X Consortium Lic...
  • Price:
  • FREE
  • Publisher Name:
  • Owen Jacobson
  • Publisher web site:
  • http://alchemy.grimoire.ca/

Wallclock Tags


Wallclock Description

Wallclock is a simple stack-based performance logger written in Python.Wallclock provides some simple tools for identifying slow parts of your code. It maintains a stack of running timers, and reports the tree of execution times when the stack empties out.Simple UsageTo time code with wallclock, use the ``push`` and ``pop`` functions provided by the wallclock module:: import wallclock def slow_function(): wallclock.push('slow function') import time time.sleep(3) wallclock.pop('slow function') def main(): wallclock.push('handling one request', enable=True) slow_function() wallclock.pop('handling one request') main()This will produce a small tree on ``stderr`` summarizing the time taken to execute ``main()``:: handling one request slow functionThe ``push`` function takes one positional argument, which is the label of the timer being pushed onto wallclock's stack. This is normally a short, descriptive label for the kind of work that happens under timing. ``push`` also takes one optional keyword argument, ``enable``, which controls whether this call to ``push`` should start timing (if it's not already started). ``wallclock`` ignores calls to ``push`` until it has been enabled, and disables itself automatically when the enabling ``push`` is ``pop``ped.The ``pop`` function takes one positional argument, which is the label to pop. This allows for simple insertion of ``push``/``pop`` pairs surrounding code that might return, or might raise an exception, without adding extra ``try``/``except`` blocks or similar (but see below for a better approach). ``wallclock`` will pop timers off of the stack until it finds a timer pushed with the passed label, or until it empties the timer stack.Product's homepage


Wallclock Related Software