You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- # -*- coding: utf-8 -*-
-
- # Simple timer to time a block of code, for optimization debugging
- # use like:
- # with nilmdb.Timer("flush"):
- # foo.flush()
-
- import contextlib
- import time
-
- @contextlib.contextmanager
- def Timer(name = None):
- start = time.time()
- yield
- elapsed = int((time.time() - start) * 1000)
- print (name or 'elapsed') + ": " + str(elapsed) + " ms"
|