Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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()
self.assertEqual(tman.size(), ntimers)
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)