Skip to content

Instantly share code, notes, and snippets.

@amitdev
Created June 13, 2013 14:12
Show Gist options
  • Save amitdev/5773979 to your computer and use it in GitHub Desktop.
Save amitdev/5773979 to your computer and use it in GitHub Desktop.
Simple benchmark script for lru dict
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