File size: 603 Bytes
371a1e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from functools import wraps
import time

from loguru import logger


# https://qiita.com/hisatoshi/items/7354c76a4412dffc4fd7
def stop_watch(func):
    """
    ε‡¦η†γ«γ‹γ‹γ‚‹ζ™‚ι–“θ¨ˆζΈ¬γ‚’γ™γ‚‹γƒ‡γ‚³γƒ¬γƒΌγ‚Ώ
    """
    @wraps(func)
    def wrapper(*args, **kargs):
        logger.debug(f"🚦 [@stop_watch] measure time to run `{func.__name__}`.")
        start = time.time()
        result = func(*args, **kargs)
        elapsed_time = time.time() - start
        logger.debug(f"🚦 [@stop_watch] take {elapsed_time:.3f} sec to run `{func.__name__}`.")
        return result
    return wrapper