""" Micro-benchmark. Run it with: ./python.orig benchmark.py script bench.py --file=orig ./python.patched benchmark.py script bench.py --file=patch ./python.patched benchmark.py compare_to orig patch Download benchmark.py from: https://bitbucket.org/haypo/misc/raw/tip/python/benchmark.py """ def run_benchmark(bench): for btype in ('bytes', 'bytearray'): bench.start_group('type %s' % btype) for length in ('10', '10**3', '10**5'): bench.timeit(setup='x = %s(b"x" * %s)' % (btype, length), stmt='x.replace(b"", b"-")', name='length=%s' % length)