Ejemplo n.º 1
0
def bm():

    fname = 'examples/const.txt'
    #fname = 'examples/einstein.txt'
    #fname = 'examples/tesla.txt'
    for _ in range(3):
        print(fname,tm(lambda: bm1(fname), number=1))
        print(fname,tm(lambda: bm2(fname), number=1))
Ejemplo n.º 2
0
def time_code(func, *args, **kwargs):
    from timeit import timeit as tm
    print(func, args)
    s = [str(_) for _ in args]
    print(
        tm("stmt=" + func + "(" + ','.join(s) + ")",
           setup="from __main__ import " + func))
def timetest():
    firstframe, firstdepth = get_numbered_frame("rawcam/out-1520009971", 214)

    def realtest():
        firstframe1, firstdepth1 = transorm_rgd_depth(firstframe, firstdepth)
        return firstframe1, firstdepth1

    print(tm(realtest, number=1))
Ejemplo n.º 4
0
def abm(n):
    print('benchmark for', n, 'array operations')
    print(tm(lambda: ranops(n), number=1))
Ejemplo n.º 5
0
def qbm(n):
    print('benchmark for', n, 'queue operations')
    print(tm(lambda: ranops(n), number=1))
Ejemplo n.º 6
0
def qbm(f, n):
    print('benchmark for sorting', n, 'numbers')
    print(tm(lambda: f(list(randints(n))), number=1))
Ejemplo n.º 7
0
"""
Recursivity timing test
Makhtar Diouf
$Id$
"""
import random
from timeit import timeit as tm
#from makhtar import utils as ut


def getsum(numlist):
    tot = 0
    for n in numlist:
        tot += n
    return tot


# With recursion, but slower!
def resum(numlist):
    if len(numlist) == 1:
        return numlist[0]
    return numlist[0] + resum(numlist[1:])


l = [x for x in range(20)]

print(l, tm("stmt=getsum(l)", setup="from __main__ import getsum, l"))

print(l, tm("stmt=resum(l)", setup="from __main__ import resum, l"))
Ejemplo n.º 8
0
"""
Recursivity timing test
Makhtar Diouf
$Id$
"""
import random
from timeit import timeit as tm
#from makhtar import utils as ut

def getsum(numlist):
    tot = 0
    for n in numlist:
        tot += n
    return tot

# With recursion, but slower!
def resum(numlist):
    if len(numlist) == 1:
        return numlist[0]
    return numlist[0] + resum(numlist[1:])

l = [x for x in range(20)]

print(l, tm("stmt=getsum(l)", setup="from __main__ import getsum, l"))

print(l, tm("stmt=resum(l)", setup="from __main__ import resum, l"))
Ejemplo n.º 9
0
def time_code(func, *args, **kwargs):
    from timeit import timeit as tm
    print(func, args)
    s = [ str(_) for _ in args]
    print(tm("stmt=" + func + "(" + ','.join(s) + ")", setup="from __main__ import "+func))