ATLAS Offline Software
timed.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaCommon import Logging
4 from ..utility import RepeatingTimer
5 import datetime
6 from functools import wraps
7 
8 
9 logger = Logging.logging.getLogger("PowhegControl")
10 
11 
12 def timed(name):
13  """! Decorator to output function execution time.
14 
15  @param name Name of the process being timed.
16 
17  @author James Robinson <james.robinson@cern.ch>
18  """
19  def wrap(func):
20  @wraps(func)
21  def wrapped_f(*args, **kwargs):
22  start_time = datetime.datetime.now()
23  logger.info("=> Preparing to run {} <=".format(name))
24  result = func(*args, **kwargs)
25  logger.info("=> Running {} took {} <=".format(name, RepeatingTimer.readable_duration(datetime.datetime.now() - start_time)))
26  return result
27  return wrapped_f
28  return wrap
python.decorators.timed.timed
def timed(name)
Decorator to output function execution time.
Definition: timed.py:12
vtune_athena.format
format
Definition: vtune_athena.py:14