code: def wrap_function(self, func):
          
  
          def f(*args, **kwds):
              self.enable_by_count()
              try:
                  result = func(*args, **kwds)
              finally:
                  self.disable_by_count()
              return result
          return f
docs: Wrap a function to profile it.