def __enter__(self):
self.start = clock()
return self
def __exit__(self,*args):
self.end = clock()
self.secs = self.end - self.start
self.msecs = self.secs * 1000 # millisecs
if self.verbose:
print 'elapsed time: %f ms' % self.msecs</code></pre>
原文链接:https://www.f2er.com/note/421879.html