jwutils: Move to jwutils -> jw.util
Move all implementation source code from the jwutils module to jw.util. For compatibility with existing Python modules, keep a thin, autogenerated compatibility shim under jwutils. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
bc7652fdf9
commit
a2684dd601
1 changed files with 678 additions and 52 deletions
25
src/python/jw/util/StopWatch.py
Normal file
25
src/python/jw/util/StopWatch.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from .log import *
|
||||
|
||||
class StopWatch: # export
|
||||
|
||||
def __init__(self, name=''):
|
||||
self.__start = datetime.now()
|
||||
self.__last = self.__start
|
||||
self.name = name
|
||||
|
||||
def reset(self):
|
||||
self.__start = datetime.now()
|
||||
|
||||
def logDelta(self, prio, *args, **kwargs):
|
||||
now = datetime.now()
|
||||
if args is not None:
|
||||
msg = ' '.join(args)
|
||||
else:
|
||||
msg = '------------------ '
|
||||
caller = kwargs['caller'] if 'caller' in kwargs.keys() else get_caller_pos(1)
|
||||
slog(prio, '{} {} {}'.format(self.name, str(now - self.__last), msg), caller=caller)
|
||||
self.__last = now
|
||||
Loading…
Reference in a new issue