""" Microbenchmark for int << int Python operation. Run it with: ./python.orig benchmark.py script bench_long_lshift.py --file=orig ./python.patched benchmark.py script bench_long_lshift.py --file=calloc ./python.patched benchmark.py compare_to orig calloc Download benchmark.py from: https://bitbucket.org/haypo/misc/raw/tip/python/benchmark.py """ def run_benchmark(bench): for shift in ('0', '1', '3', '5', '10', '15', '20', '25', '28'): bench.timeit('1 << shift', setup='shift = 2 ** %s' % shift, name='1 << (2 ** %s)' % shift) bench.timeit('123 << 1') bench.timeit('12345678 << 1') bench.timeit('12345678 << 100') if __name__ == "__main__": import benchmark benchmark.main()