numpy.testing.utils.jiffies

Here are the examples of the python api numpy.testing.utils.jiffies taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

Example 1

Project: robothon Source File: numpytest.py
    def measure(self,code_str,times=1):
        """ Return elapsed time for executing code_str in the
        namespace of the caller for given times.
        """
        frame = get_frame(1)
        locs,globs = frame.f_locals,frame.f_globals
        code = compile(code_str,
                       'NumpyTestCase runner for '+self.__class__.__name__,
                       'exec')
        i = 0
        elapsed = jiffies()
        while i<times:
            i += 1
            exec code in globs,locs
        elapsed = jiffies() - elapsed
        return 0.01*elapsed

Example 2

Project: robothon Source File: f2py_testing.py
Function: run
def run(runtest,test_functions,repeat=1):
    l = [(t,repr(t.__doc__.split('\n')[1].strip())) for t in test_functions]
    #l = [(t,'') for t in test_functions]
    start_memusage = memusage()
    diff_memusage = None
    start_jiffies = jiffies()
    i = 0
    while i<repeat:
        i += 1
        for t,fname in l:
            runtest(t)
            if start_memusage is None: continue
            if diff_memusage is None:
                diff_memusage = memusage() - start_memusage
            else:
                diff_memusage2 = memusage() - start_memusage
                if diff_memusage2!=diff_memusage:
                    print 'memory usage change at step %i:' % i,\
                          diff_memusage2-diff_memusage,\
                          fname
                    diff_memusage = diff_memusage2
    current_memusage = memusage()
    print 'run',repeat*len(test_functions),'tests',\
          'in %.2f seconds' % ((jiffies()-start_jiffies)/100.0)
    if start_memusage:
        print 'initial virtual memory size:',start_memusage,'bytes'
        print 'current virtual memory size:',current_memusage,'bytes'

Example 3

Project: AWS-Lambda-ML-Microservice-Skeleton Source File: f2py_testing.py
def run(runtest, test_functions, repeat=1):
    l = [(t, repr(t.__doc__.split('\n')[1].strip())) for t in test_functions]
    start_memusage = memusage()
    diff_memusage = None
    start_jiffies = jiffies()
    i = 0
    while i < repeat:
        i += 1
        for t, fname in l:
            runtest(t)
            if start_memusage is None:
                continue
            if diff_memusage is None:
                diff_memusage = memusage() - start_memusage
            else:
                diff_memusage2 = memusage() - start_memusage
                if diff_memusage2 != diff_memusage:
                    print('memory usage change at step %i:' % i,
                          diff_memusage2 - diff_memusage,
                          fname)
                    diff_memusage = diff_memusage2
    current_memusage = memusage()
    print('run', repeat * len(test_functions), 'tests',
          'in %.2f seconds' % ((jiffies() - start_jiffies) / 100.0))
    if start_memusage:
        print('initial virtual memory size:', start_memusage, 'bytes')
        print('current virtual memory size:', current_memusage, 'bytes')