changeset 990:fb3e23e8d36d

Document begin/end.
author Martin Geisler <mg@daimi.au.dk>
date Wed, 01 Oct 2008 11:19:44 +0200
parents 1d6860a2534f
children afe30d97ec32
files viff/util.py
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/viff/util.py	Wed Oct 01 11:08:42 2008 +0200
+++ b/viff/util.py	Wed Oct 01 11:19:44 2008 +0200
@@ -253,10 +253,29 @@
 PHASES = {}
 
 def begin(result, phase):
+    """Begin a phase.
+
+    You can define program phases for the purpose of profiling a
+    program execution. Use :func:`end` with a matching *phase* to
+    record the ending of a phase. The :func:`profile` decorator makes
+    it easy to wrap a :class:`Runtime <viff.runtime.Runtime>` method
+    in matching :func:`begin`/:func:`end` calls.
+
+    The *result* argument is passed through, which makes it possible
+    to add this function as a callback for a :class:`Deferred`.
+    """
     PHASES[phase] = time.time()
     return result
 
 def end(result, phase):
+    """End a phase.
+
+    This is the counter-part for :func:`begin`. It prints the name and
+    the duration of the phase.
+
+    The *result* argument is passed through, which makes it possible
+    to add this function as a callback for a :class:`Deferred`.
+    """
     stop = time.time()
     start = PHASES.pop(phase, stop)
     print "%s from %f to %f (%f sec)" % (phase, start, stop, stop - start)