How to use the timemory.LINE 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 / examples / simple.py View on Github external
def main(nfib):
    print ('')
    print ('main: file() {}'.format(tim.FILE()))
    print ('main: line() {}'.format(tim.LINE()))
    print ('main: line() {}'.format(tim.LINE()))
    print ('main: func() {}'.format(tim.FUNC()))
    test()
    print ('')
    tman = tim.timing_manager()
    calcfib(int(nfib))
    tman.report()
    tman.serialize('output.json')
    print ('')
    tim.plot.plot(["output.json"], display=False)
github NERSC / timemory / examples / nested.py View on Github external
def fibonacci(n):
    if n < 2:
        return n 
    autotimer = tim.auto_timer('({})@{}:{}'.format(n, tim.FILE(), tim.LINE()))
    return fibonacci(n-1) + fibonacci(n-2)
github NERSC / timemory / examples / nested.py View on Github external
def func_3(n):
    autotimer = tim.auto_timer('{}:{}'.format(tim.FILE(), tim.LINE()))
    func_1(n)
    func_2(n)
github NERSC / timemory / examples / nested.py View on Github external
def func_2(n):
    autotimer = tim.auto_timer('{}:{}'.format(tim.FILE(), tim.LINE()))
    func_1(n)
    fibonacci(n)
github NERSC / timemory / examples / nested.py View on Github external
def func_mem(n=array_size):
    autotimer = tim.auto_timer('{}:{}'.format(tim.FILE(), tim.LINE()))
github NERSC / timemory / examples / nested.py View on Github external
def main(nfib):
    autotimer = tim.auto_timer('{}:{}'.format(tim.FILE(), tim.LINE()))
    for i in range(2):
        func_1(nfib)
    func_2(nfib)
    func_3(nfib)
github NERSC / timemory / timemory / util / util.py View on Github external
def __call__(self, func):
        """
        Decorator
        """
        import timemory
        _file = timemory.FILE(3)
        _line = timemory.LINE(2)

        @wraps(func)
        def function_wrapper(*args, **kwargs):
            self.parse_wrapped(func, args, kwargs)
            self.determine_signature(is_decorator=True, is_context_manager=False)

            _func = func.__name__
            _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)
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)
github NERSC / timemory / timemory / util / util.py View on Github external
def __call__(self, func):
        """
        Decorator
        """
        import timemory
        _file = timemory.FILE(3)
        _line = timemory.LINE(2)

        @wraps(func)
        def function_wrapper(*args, **kwargs):
            self.parse_wrapped(func, args, kwargs)
            self.determine_signature(is_decorator=True, is_context_manager=False)

            _func = func.__name__
            _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)