changeset 989:1d6860a2534f

Document profile decorator.
author Martin Geisler <mg@daimi.au.dk>
date Wed, 01 Oct 2008 11:08:42 +0200
parents 6612f982d5e2
children fb3e23e8d36d
files doc/util.txt viff/util.py
diffstat 2 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/doc/util.txt	Wed Oct 01 11:02:40 2008 +0200
+++ b/doc/util.txt	Wed Oct 01 11:08:42 2008 +0200
@@ -25,3 +25,8 @@
 
       Setting this environment variable to any value will turn
       :func:`wrapper` into a no-op.
+
+   .. envvar:: VIFF_PROFILE
+
+      Defining this variable will change :func:`profile` from a no-op
+      to real decorator.
--- a/viff/util.py	Wed Oct 01 11:02:40 2008 +0200
+++ b/viff/util.py	Wed Oct 01 11:08:42 2008 +0200
@@ -263,6 +263,16 @@
     return result
 
 def profile(method):
+    """Profiling decorator.
+
+    Add this decorator to a method in order to trace method entry and
+    exit. If the method returns a :class:`Deferred`, the method exit
+    is recorded when the :class:`Deferred` fires.
+
+    In addition to adding this decorator, you must run the programs in
+    an environment with :envvar:`VIFF_PROFILE` defined. Otherwise the
+    decorator is a no-op and has no runtime overhead.
+    """
     if not os.environ.get('VIFF_PROFILE'):
         return method