import pyperf SETUP_FUNC="""if 1: a = 1 b = 2 c = -1 d = 9 e = -20 """ runner = pyperf.Runner() runner.timeit( name="max(a, b)", stmt="max(a, b)", setup=SETUP_FUNC, ) runner.timeit( name="max(a, b, c, d, e)", stmt="max(a, b, c, d, e)", setup=SETUP_FUNC, ) runner.timeit( name="max([a, b])", stmt="max([a, b])", setup=SETUP_FUNC, ) runner.timeit( name="max([a, b, c, d, e])", stmt="max([a, b, c, d, e])", setup=SETUP_FUNC, ) runner.timeit( name="max((a,), (b,), key=lambda x: x[0])", stmt="max((a,), (b,), key=lambda x: x[0])", setup=SETUP_FUNC, ) runner.timeit( name="max((a,), (b,), (c,), (d,), (e,), key=lambda x: x[0])", stmt="max((a,), (b,), (c,), (d,), (e,), key=lambda x: x[0])", setup=SETUP_FUNC, ) runner.timeit( name="max([(a,), (b,)], key=lambda x: x[0])", stmt="max([(a,), (b,)], key=lambda x: x[0])", setup=SETUP_FUNC, ) runner.timeit( name="max([(a,), (b,), (c,), (d,), (e,)], key=lambda x: x[0])", stmt="max([(a,), (b,), (c,), (d,), (e,)], key=lambda x: x[0])", setup=SETUP_FUNC, ) runner.timeit( name="max([], default=-1)", stmt="max([], default=-1)", setup=SETUP_FUNC, )