Exemplo n.º 1
0
def timeit(n=10, m=10):
    k = 10000 // n # number of trials, for timing

    gambles = [
        dict((i, random.randint(1, m))
             for i in xrange(n))
        for j in xrange(k)]

    pspace = PSpace(n)
    s = SetFunction(
        pspace=pspace,
        number_type='fraction')
    # hack so we do not need to fill the set function with data
    # (this solves issues when testing for large n)
    s._data = defaultdict(lambda: random.randint(-len(pspace), len(pspace)))

    t = time.clock()
    for gamble in gambles:
        s.get_choquet(gamble)
    return time.clock() - t