Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from yahi.fixed_size_dict import *
- from time import time
- sample=1000000
- def time_for(size, constructor):
- if constructor==dict:
- a=dict()
- else:
- a=constructor(size)
- print "size %d" % size
- print "fact %s" % repr(constructor.__name__)
- start = time()
- for i in range(sample):
- a[i]=i
- print "took %f" % (time() - start)
- for size in [ 10, 100, 1000, 10000]:
- for constructor in bmFixedLookupTable, FixedLookupTable,dict:
- time_for(size,constructor)
- """size 10
- fact 'bmFixedLookupTable'
- took 1.424893
- size 10
- fact 'FixedLookupTable'
- took 2.594238
- size 10
- fact 'dict'
- took 0.215046
- size 100
- fact 'bmFixedLookupTable'
- took 1.356977
- size 100
- fact 'FixedLookupTable'
- took 2.579066
- size 100
- fact 'dict'
- took 0.212382
- size 1000
- fact 'bmFixedLookupTable'
- took 1.359531
- size 1000
- fact 'FixedLookupTable'
- took 2.551217
- size 1000
- fact 'dict'
- took 0.213694
- size 10000
- fact 'bmFixedLookupTable'
- took 1.415309
- size 10000
- fact 'FixedLookupTable'
- took 2.686362
- size 10000
- fact 'dict'
- took 0.212665
- """
Add Comment
Please, Sign In to add comment