Skip to content

Instantly share code, notes, and snippets.

@eevmanu
Created March 6, 2017 04:56
Show Gist options
  • Save eevmanu/5755f25eb03c1f54da7beadf516ac5bb to your computer and use it in GitHub Desktop.
Save eevmanu/5755f25eb03c1f54da7beadf516ac5bb to your computer and use it in GitHub Desktop.
how to do a simple benchmarking with timeit
def a():
x = 'XBmYxJY6pP64vV4Km7pnxuC854XweJ6TkuuBvd5SDd64HZcfM5wZxH5GPX4n'
x = x[::-1]
def b():
x = 'v3xy4FMR25vmy8FznB2RzE3b649rS7v9ez5Z4yTAdye6nWw5t928ac7dP3S2'
x = x[::-1]
def c():
x = 'K5uhJpUC8Xpw7Z4Qbb5G2PM687qRJbwc6v94kN8C2c5eR3Mg7t23MkCBVfVm'
x = x[::-1]
def d():
a()
b()
c()
# python -m timeit -s 'import tmp3' 'tmp3.a()' 'tmp3.b()' 'tmp3.c()'
# python -m timeit -s 'import tmp3' 'tmp3.d()'
# python -m timeit -n 10000000 -r 5 -s 'import tmp3' 'tmp3.a()' 'tmp3.b()' 'tmp3.c()'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment