Skip to content

Instantly share code, notes, and snippets.

@higumachan
Created January 17, 2017 10:25
Show Gist options
  • Save higumachan/49ee4e1cd8802cb83711c31081c397cd to your computer and use it in GitHub Desktop.
Save higumachan/49ee4e1cd8802cb83711c31081c397cd to your computer and use it in GitHub Desktop.
from itertools import imap
import timeit
if __name__ == '__main__':
cached_time = timeit.timeit("map(_ + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1+ 1 + 1 + 1 + 1 + 1+ 1 + 1 + 1 + 1 + 1+ 1 + 1 + 1 + 1 + 1, xrange(1000))", setup="from pyscalambda import _", number=100)
nocached_time = timeit.timeit("map((_ + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1+ 1 + 1 + 1 + 1 + 1+ 1 + 1 + 1 + 1 + 1+ 1 + 1 + 1 + 1 + 1).nocache(), xrange(1000))", setup="from pyscalambda import _", number=100)
print(cached_time, nocached_time)
print(nocached_time / cached_time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment