Skip to content

Commit

Permalink
Add timing directive
Browse files Browse the repository at this point in the history
  • Loading branch information
timothycrosley committed Aug 8, 2015
1 parent 7d22623 commit 97dfb07
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions hug/directives.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from timeit import default_timer as timer


class Timer(object):
__slots__ = ('start', 'format')

def __init__(self, format=None, **kwargs):
self.start = timer()
self.format = format

def taken(self):
return (self.format.format or float)(timer() - self.start)

timer = Timer


0 comments on commit 97dfb07

Please sign in to comment.