def test_stopwatch_checkpoint(self): stopwatch = StopWatch() start_time = stopwatch.start() checkpoint_1 = stopwatch.checkpoint() checkpoint_2 = stopwatch.checkpoint() elapsed_time = stopwatch.stop() self.assertTrue(checkpoint_1 + checkpoint_2 <= elapsed_time)
print awesome_sum(5, 10) print awesome_mul(5, 10) awesome_print() watch = StopWatch() watch.start() for i in range(100000): pass print ('Time is running out.. {0} sec.'.format(watch.elapsed_time)) for i in range(10000000): pass watch.stop() print ('Time spent in range: {0} sec.'.format(watch.elapsed_time)) with stopwatchcm(callback=stopwatch_sum_cb_w_cm): c = 5 * 10 watch = StopWatch() watch.start() for i in range(10000000): pass print ('Time spent in first range: {0} sec.'.format(watch.checkpoint())) for i in range(10000000): pass print ('Time spent in second range: {0} sec.'.format(watch.checkpoint())) for i in range(10000000): pass print ('Time spent in third range: {0} sec.'.format(watch.checkpoint())) watch.stop() print ('Time spent in range total: {0} sec.'.format(watch.elapsed_time))