Created
June 13, 2013 14:12
-
-
Save amitdev/5773979 to your computer and use it in GitHub Desktop.
Simple benchmark script for lru dict
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
import resource | |
s = sys.argv[1].split('.') | |
lru = __import__(s[0]).__dict__[s[1]] | |
m = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss | |
t = time.clock() | |
cache = lru(1000000) | |
for i in xrange(1100000): | |
cache[i] = i | |
print "Time : %r s, Memory : %r Kb" % (time.clock()-t, | |
resource.getrusage(resource.RUSAGE_SELF).ru_maxrss - m) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment