Commit 9b08e26b by John Eskew

Add setup.py and __init__.py

parent 07147334
......@@ -2,5 +2,5 @@ Python module which puts timing around Python code blocks.
Features
--------
* Nesting of timers - higher level timers continue to tick during lower-level timers starting/stopping.
* Timing storage in a SQLite DB.
* Nesting of timers - higher level timers continue to tick during lower-level timers starting/stopping. (TBD)
* Timing storage in a SQLite DB. (TBD)
from timeit import default_timer
class CodeBlockTimer(object):
def __init__(self, block_desc, verbose=False):
self.block_desc = block_desc
self.verbose = verbose
self.timer = default_timer
def __enter__(self):
self.start = self.timer()
return self
def __exit__(self, *args):
end = self.timer()
self.elapsed_secs = end - self.start
self.elapsed = self.elapsed_secs * 1000 # millisecs
if self.verbose:
print '{}: elapsed time: {} ms'.format(self.block_desc, self.elapsed)
from setuptools import setup
setup(
name="code_block_timer",
version="0.0.1",
packages=[
"code_block_timer",
],
author_email='jeskew@edx.org'
)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment