""" Run it using: python benchmark.py script bench_hash.py --file=FILENAME https://bitbucket.org/haypo/misc/src/tip/python/benchmark.py """ def run_benchmark(bench): for length in ('1', '3', '10', '20', '100', '10 ** 4', '10 ** 8'): bench.start_group('Length %s' % length) for charset in ('a', '\u20ac', '\U0010ffff'): bench.timeit('hash(s)', setup='s = %r * %s' % (charset, length), name='hash(%a * %s)' % (charset, length))