mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Timing infrastructure for the content server
This commit is contained in:
parent
10ad5cabcc
commit
d7fa2363a8
@ -5,7 +5,9 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
from calibre import strftime as _strftime
|
import time
|
||||||
|
|
||||||
|
from calibre import strftime as _strftime, prints
|
||||||
from calibre.utils.date import now as nowf
|
from calibre.utils.date import now as nowf
|
||||||
|
|
||||||
|
|
||||||
@ -20,6 +22,19 @@ def expose(func):
|
|||||||
|
|
||||||
return cherrypy.expose(do)
|
return cherrypy.expose(do)
|
||||||
|
|
||||||
|
def timeit(func):
|
||||||
|
|
||||||
|
def do(self, *args, **kwargs):
|
||||||
|
if self.opts.develop:
|
||||||
|
start = time.time()
|
||||||
|
ans = func(self, *args, **kwargs)
|
||||||
|
if self.opts.develop:
|
||||||
|
prints('Function', func.__name__, 'called with args:', args, kwargs)
|
||||||
|
prints('\tTime:', func.__name__, time.time()-start)
|
||||||
|
return ans
|
||||||
|
|
||||||
|
return do
|
||||||
|
|
||||||
def strftime(fmt='%Y/%m/%d %H:%M:%S', dt=None):
|
def strftime(fmt='%Y/%m/%d %H:%M:%S', dt=None):
|
||||||
if not hasattr(dt, 'timetuple'):
|
if not hasattr(dt, 'timetuple'):
|
||||||
dt = nowf()
|
dt = nowf()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user