Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tman = timing.timing_manager()
timing.toggle(True)
timing.set_max_depth(timing.util.default_max_depth())
tman.clear()
timing.toggle(True)
if True:
autotimer = timing.auto_timer("on")
fibonacci(27)
del autotimer
self.assertEqual(tman.size(), 1)
tman.clear()
timing.toggle(False)
if True:
autotimer = timing.auto_timer("off")
fibonacci(27)
del autotimer
self.assertEqual(tman.size(), 0)
tman.clear()
timing.toggle(True)
if True:
autotimer_on = timing.auto_timer("on")
timing.toggle(False)
autotimer_off = timing.auto_timer("off")
fibonacci(27)
del autotimer_off
del autotimer_on
self.assertEqual(tman.size(), 1)
n = i - 12
time_fibonacci(n - 2)
time_fibonacci(n - 1)
time_fibonacci(n)
time_fibonacci(n + 1)
tman.merge()
tman.report()
self.assertEqual(tman.size(), 12)
for i in range(0, tman.size()):
t = tman.at(i)
self.assertFalse(t.real_elapsed() < 0.0)
self.assertFalse(t.user_elapsed() < 0.0)
timing.toggle(True)
def test_max_depth(self):
print ('Testing function: "{}"...'.format(timing.FUNC()))
tman = timing.timing_manager()
timing.toggle(True)
tman.clear()
def create_timer(n):
autotimer = timing.auto_timer('{}'.format(n))
fibonacci(30)
if n < 8:
create_timer(n + 1)
ntimers = 4
timing.set_max_depth(ntimers)
create_timer(0)
timing.util.opts.set_report(join(self.outdir, "timing_depth.out"))
timing.util.opts.set_serial(join(self.outdir, "timing_depth.json"))
tman.report()
def test_toggle(self):
print ('Testing function: "{}"...'.format(timing.FUNC()))
tman = timing.timing_manager()
timing.toggle(True)
timing.set_max_depth(timing.util.default_max_depth())
tman.clear()
timing.toggle(True)
if True:
autotimer = timing.auto_timer("on")
fibonacci(27)
del autotimer
self.assertEqual(tman.size(), 1)
tman.clear()
timing.toggle(False)
if True:
autotimer = timing.auto_timer("off")
fibonacci(27)
del autotimer
self.assertEqual(tman.size(), 0)
tman.clear()
timing.toggle(True)
del autotimer
self.assertEqual(tman.size(), 1)
tman.clear()
timing.toggle(False)
if True:
autotimer = timing.auto_timer("off")
fibonacci(27)
del autotimer
self.assertEqual(tman.size(), 0)
tman.clear()
timing.toggle(True)
if True:
autotimer_on = timing.auto_timer("on")
timing.toggle(False)
autotimer_off = timing.auto_timer("off")
fibonacci(27)
del autotimer_off
del autotimer_on
self.assertEqual(tman.size(), 1)
timing.util.opts.set_report(join(self.outdir, "timing_toggle.out"))
timing.util.opts.set_serial(join(self.outdir, "timing_toggle.json"))
tman.report()
def parse_args(args):
# Function to handle the output arguments
opts.serial_report = args.serial_report
opts.use_timers = args.use_timers
opts.max_timer_depth = args.max_timer_depth
_report_fname = "{}.{}".format(args.filename, "out")
_serial_fname = "{}.{}".format(args.filename, "json")
opts.report_fname = join(args.output_dir, _report_fname);
opts.serial_fname = join(args.output_dir, _serial_fname);
import timemory as tim
tim.toggle(opts.use_timers)
tim.set_max_depth(opts.max_timer_depth)