def load(self): # Retrieve current mode self.mode = self.task.configuration['sync.profiler'] # Setup profilers if self.mode == SyncProfilerMode.Basic: # Enable elapsed.py elapsed.setup(enabled=True) log.info('Enabled profiler: elapsed.py (basic)') else: # Ensure elapsed.py is disabled elapsed.setup(enabled=False)
time.sleep(float(random.randint(0, 250)) / 1000) for x in xrange(3): self.three() @classmethod @elapsed.clock def two(cls): time.sleep(float(random.randint(0, 250)) / 1000) with elapsed.clock(Example, "two:sub"): for x in xrange(3): time.sleep(float(random.randint(0, 250)) / 1000) @elapsed.clock def three(self): time.sleep(float(random.randint(0, 250)) / 1000) if __name__ == "__main__": logging.basicConfig(level=logging.DEBUG) elapsed.setup(enabled=True) app = Example() app.run() elapsed.print_report() print "Done"