Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #default
- Mul: 1.0457470417
- Div: 2.65450692177
- Sub: 0.871921062469
- Divmod: 1.95720386505
- Combo: 5.96903395653
- Mul: 1.01342606544
- Div: 2.71628308296
- Sub: 0.875638008118
- Divmod: 1.95388221741
- Combo: 6.09685087204
- Mul: 1.00868797302
- Div: 2.707862854
- Sub: 0.874716997147
- Divmod: 1.94629001617
- Combo: 6.09136390686
- # math-improvement branch
- Mul: 1.01715111732
- Div: 2.44827103615
- Sub: 0.700042963028
- Divmod: 1.807336092
- Combo: 5.29910898209
- Mul: 0.982100009918
- Div: 2.4520919323
- Sub: 0.691036939621
- Divmod: 1.81433415413
- Combo: 5.25664901733
- Mul: 0.98149394989
- Div: 2.45189714432
- Sub: 0.691314935684
- Divmod: 1.8157248497
- Combo: 5.25712394714
- bench.py:
- from time import time
- def bench_mul():
- for x in range(50000000):
- l = long(x)
- l *= 2 # mul, power of two
- l *= 3 # mul, not power of two
- def bench_div():
- for x in range(50000000):
- l = long(x)
- l //= 2 # floordiv, power of two
- l //= 3 # floordiv, not power of two
- def bench_sub():
- for x in range(50000000):
- l = long(x)
- l -= 1 # sub
- def bench_divmod():
- for x in range(50000000):
- l = long(x)
- r, m = divmod(l, 3) # divmod
- def bench_combo():
- for x in range(50000000):
- l = long(x)
- l *= 2
- l //= 2
- l *= 3
- l //= 3
- l -= 1
- r, m = divmod(l, 3) # divmod
- for x in range(3):
- t = time()
- bench_mul()
- print "Mul:", time() - t
- t = time()
- bench_div()
- print "Div:", time() - t
- t = time()
- bench_sub()
- print "Sub:", time() - t
- t = time()
- bench_divmod()
- print "Divmod:", time() - t
- t = time()
- bench_combo()
- print "Combo:", time() - t
- print ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement