Joshua Harlow 346c27b735 Add useful 'time_it' decorator
Create a helpful decorator that can be attached to functions
or methods to show how long they take to run; internally it
uses a stop watch and provided logger to log with (and an
optional logging level to use).

An example:

>>> from oslo_utils import timeutils
>>> import logging
>>> import time
>>> logging.basicConfig(level=logging.DEBUG)
>>> logger = logging.getLogger()
>>>
>>> @timeutils.time_it(logger)
... def a():
...   time.sleep(0.2)
...
>>> a()
DEBUG:root:It took 0.20 seconds to run function '__main__.a'

Change-Id: Ia41d5b6910f7ebe2dd93aaf6ca1defe158f8310c
2015-11-13 10:29:36 -08:00
..
2015-11-13 10:29:36 -08:00
2015-01-16 16:19:54 -06:00
2015-11-13 10:29:36 -08:00