ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Generators
PowhegControl
python
decorators
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
..
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
Generated on
for ATLAS Offline Software by
1.17.0