http://docs.python.org/2/library/timeit.html

examples/advanced/benchmark.py
import timeit

import random
chars = []
for i in xrange(200):
    chars.append(chr(65 + random.randrange(0, 26)))

print(timeit.timeit('str = "".join(chars)',
    setup="from __main__ import chars", number=10000))

print(timeit.timeit('reduce(lambda x, y: x+y, chars)',
    setup="from __main__ import chars", number=10000))
examples/advanced/benchmark.out
0.0351030826569
0.356314897537