mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 18:13:04 +02:00
Timing infrastructure for the content server
This commit is contained in:
parent
10ad5cabcc
commit
d7fa2363a8
1 changed files with 16 additions and 1 deletions
|
|
@ -5,7 +5,9 @@
|
|||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__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
|
||||
|
||||
|
||||
|
|
@ -20,6 +22,19 @@ def do(self, *args, **kwargs):
|
|||
|
||||
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):
|
||||
if not hasattr(dt, 'timetuple'):
|
||||
dt = nowf()
|
||||
|
|
|
|||
Loading…
Reference in a new issue