viff

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 diff
     1.1 --- a/doc/util.txt	Wed Oct 01 11:02:40 2008 +0200
     1.2 +++ b/doc/util.txt	Wed Oct 01 11:08:42 2008 +0200
     1.3 @@ -25,3 +25,8 @@
     1.4  
     1.5        Setting this environment variable to any value will turn
     1.6        :func:`wrapper` into a no-op.
     1.7 +
     1.8 +   .. envvar:: VIFF_PROFILE
     1.9 +
    1.10 +      Defining this variable will change :func:`profile` from a no-op
    1.11 +      to real decorator.
     2.1 --- a/viff/util.py	Wed Oct 01 11:02:40 2008 +0200
     2.2 +++ b/viff/util.py	Wed Oct 01 11:08:42 2008 +0200
     2.3 @@ -263,6 +263,16 @@
     2.4      return result
     2.5  
     2.6  def profile(method):
     2.7 +    """Profiling decorator.
     2.8 +
     2.9 +    Add this decorator to a method in order to trace method entry and
    2.10 +    exit. If the method returns a :class:`Deferred`, the method exit
    2.11 +    is recorded when the :class:`Deferred` fires.
    2.12 +
    2.13 +    In addition to adding this decorator, you must run the programs in
    2.14 +    an environment with :envvar:`VIFF_PROFILE` defined. Otherwise the
    2.15 +    decorator is a no-op and has no runtime overhead.
    2.16 +    """
    2.17      if not os.environ.get('VIFF_PROFILE'):
    2.18          return method
    2.19