How to use the timemory.FUNC 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_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)
github NERSC / timemory / python / unit_testing.py View on Github external
def test_pointer(self):
        print ('Testing function: "{}"...'.format(timing.FUNC()))

        nval = 4

        def set_pointer_max(nmax):
            tman = timing.timing_manager()
            tman.set_max_depth(4)
            return tman.get_max_depth()

        def get_pointer_max():
            return timing.timing_manager().get_max_depth()

        ndef = get_pointer_max()
        nnew = set_pointer_max(nval)
        nchk = get_pointer_max()

        self.assertEqual(nval, nchk)
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)
github NERSC / timemory / examples / simple.py View on Github external
def test():
    print ('test: func() {}'.format(tim.FUNC()))
    print ('test: func(2) {}'.format(tim.FUNC(2)))
github NERSC / timemory / examples / simple.py View on Github external
def test():
    print ('test: func() {}'.format(tim.FUNC()))
    print ('test: func(2) {}'.format(tim.FUNC(2)))
github NERSC / timemory / timemory / util / util.py View on Github external
def __enter__(self, *args, **kwargs):
        """
        Context manager entrance
        """
        import timemory
        _file = timemory.FILE(3)
        _line = timemory.LINE(2)
        _func = timemory.FUNC(2)
        self.determine_signature(is_decorator=False, is_context_manager=True)

        _key = ''
        _args = self.arg_string(args, kwargs)
        if self.signature == context.blank:
            _key = '{}{}'.format(self.key, _args)
        elif self.signature == context.basic:
            _key = '{}/{}/{}'.format(_func, self.key, _args)
        elif self.signature == context.full:
            _key = '{}/{}:{}/{}{}'.format(
                _func, _file, _line, self.key, _args)
        _key = _key.strip('/')

        self._self_obj = timemory.rss_usage(_key)
        self._self_dif = timemory.rss_usage(_key)
        self._self_dif.record()