How to use the timemory.set_max_depth function in timemory

To help you get started, we’ve selected a few timemory examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NERSC / timemory / python / unit_testing.py View on Github external
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)
github NERSC / timemory / python / unit_testing.py View on Github external
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)
github NERSC / timemory / python / options.py View on Github external
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)