Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more logging info in the timing decorator
- Loading branch information
Showing
1 changed file
with
7 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
"""Common decorator utilities | ||
""" | ||
|
||
import time | ||
from datetime import datetime | ||
|
||
|
||
def timeit(method): | ||
"""Timing decorator for measuring performance of functions | ||
""" | ||
|
||
def timed(*args, **kw): | ||
ts = time.time() | ||
ts = datetime.now() | ||
print 'Starting time for Method %r is %s' % (method.__name__, ts) | ||
|
||
result = method(*args, **kw) | ||
te = time.time() | ||
te = datetime.now() | ||
print 'End time for Method %r is %s' % (method.__name__, te) | ||
|
||
print 'Method %r with arguments (%r, %r) took %2.2f secs' % \ | ||
(method.__name__, args, kw, te-ts) | ||
(method.__name__, args, kw, (te-ts).total_seconds()) | ||
return result | ||
|
||
return timed |