Skip to content

Instantly share code, notes, and snippets.

@michaelosthege
Created July 6, 2017 12:05

Revisions

  1. michaelosthege created this gist Jul 6, 2017.
    15 changes: 15 additions & 0 deletions benchmark.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    import time

    class Measurement(object):
    def __init__(self, name):
    self.name = name
    return

    def __enter__(self):
    self.t_start = time.time()
    return

    def __exit__(self, exc_type, exc_val, exc_tb):
    t_end = time.time()
    print("{} took {:.3f} seconds".format(self.name, t_end - self.t_start))
    return