Skip to content

Commit

Permalink
[#2375] add helper decorator for timings
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Aug 1, 2012
1 parent 8e9c449 commit d54ab13
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ckan/lib/maintain.py
Expand Up @@ -75,3 +75,13 @@ def defer_context_item(item_name, function):
assert hasattr(function, '__call__'), 'must pass a function'
setattr(c, item_name, property(function))



def timer(fn):
fn_name = fn.__name__
def wrapped(*args, **kw):
start = time.time()
result = fn(*args, **kw)
log.info('%s %f.4' % (fn_name, time.time() - start))
return result
return wrapped

0 comments on commit d54ab13

Please sign in to comment.