Skip to content

timeit for differents lenghts of the same stmt #1

@asdf8601

Description

@asdf8601

I would like generalize this to include it in timer_plus.

def benchmark_this(fun, *args, N=None):
    res = []
    if N is None:
        N = map(lambda i: 10**i, range(7))
    
    for Ni in N:
        x = np.tile(range(10), Ni)
        n = np.array([1, 1, 1, 1], dtype=np.int64)
        stmt = "func(*args)"

        t = timer_plus.Timer(stmt, globals=locals())
        t.repeat_autorange(10)
        r = t.statistics
        r.name = "N=%s" % len(x)
        res += [r]

    print(pd.concat(res, axis=1))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions