a '¡Dgg ã@sNddlZddlZddlZe e¡ZGdd„dƒZdddœeeedœdd „Z dS) éNc@s:eZdZdZdddœeeedœdd„Zdd „Zd d „Zd S) ÚTimeda¾ A context manager which measures and optionally logs context run time. :param msg: A message that describes the thing that is being measured :param threshold: Threshold, in seconds. When the context exceeds this threshold, a log will be made. :param log_mode: Control whether to log. Defaults to "threshold". Possible values include: "always" - Always log 'msg', even when 'threshold' is not reached. "threshold" - Log when context time exceeds 'threshold'. "skip" - Do not log. Context time and message are stored in the 'output' and 'delta' attributes, respectively. Used to manually coalesce with other logs at the call site. usage: this call: ``` with Timed("Configuring the network"): run_configure() ``` might produce this log: ``` Configuring the network took 0.100 seconds ``` ç{®Gáz„?Ú threshold©rÚlog_mode©ÚmsgrrcCs(||_||_||_d|_d|_d|_dS)NÚg)rrrÚoutputÚstartÚdelta)Úselfrrr©rú9/usr/lib/python3.9/site-packages/cloudinit/performance.pyÚ__init__%s zTimed.__init__cCst ¡|_|S)N)ÚtimeÚ monotonicr )r rrrÚ __enter__3s zTimed.__enter__cCsšt ¡|j|_d|jd›d�}d|jkr.wrapper..decorator)Ú functoolsÚwraps)r%r&©rrr)r%rÚwrappercsztimed..wrapperr)rrrr*rr)rÚtimedHsr+) r'ZloggingrZ getLoggerrrrr!r"r+rrrrÚs  @