Guest User

Untitled

a guest
Oct 22nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. from yahi.fixed_size_dict import *
  2. from time import time
  3. sample=1000000
  4. def time_for(size, constructor):
  5. if constructor==dict:
  6. a=dict()
  7. else:
  8. a=constructor(size)
  9. print "size %d" % size
  10. print "fact %s" % repr(constructor.__name__)
  11. start = time()
  12. for i in range(sample):
  13. a[i]=i
  14. print "took %f" % (time() - start)
  15. for size in [ 10, 100, 1000, 10000]:
  16. for constructor in bmFixedLookupTable, FixedLookupTable,dict:
  17. time_for(size,constructor)
  18.  
  19. """size 10
  20. fact 'bmFixedLookupTable'
  21. took 1.424893
  22. size 10
  23. fact 'FixedLookupTable'
  24. took 2.594238
  25. size 10
  26. fact 'dict'
  27. took 0.215046
  28. size 100
  29. fact 'bmFixedLookupTable'
  30. took 1.356977
  31. size 100
  32. fact 'FixedLookupTable'
  33. took 2.579066
  34. size 100
  35. fact 'dict'
  36. took 0.212382
  37. size 1000
  38. fact 'bmFixedLookupTable'
  39. took 1.359531
  40. size 1000
  41. fact 'FixedLookupTable'
  42. took 2.551217
  43. size 1000
  44. fact 'dict'
  45. took 0.213694
  46. size 10000
  47. fact 'bmFixedLookupTable'
  48. took 1.415309
  49. size 10000
  50. fact 'FixedLookupTable'
  51. took 2.686362
  52. size 10000
  53. fact 'dict'
  54. took 0.212665
  55. """
Add Comment
Please, Sign In to add comment