Skip to content

Instantly share code, notes, and snippets.

@fccoelho
Created May 26, 2015 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fccoelho/fc77e7f3917b761a258b to your computer and use it in GitHub Desktop.
Save fccoelho/fc77e7f3917b761a258b to your computer and use it in GitHub Desktop.
MongoDict benchmark
"""
In [16]: %timeit dic_normal(1000)
1000 loops, best of 3: 802 µs per loop
In [17]: %timeit dic_mongo(1000)
1 loops, best of 3: 308 ms per loop
In [18]: dic2 = dic_normal(1000)
In [19]: %time col.insert(dic2)
CPU times: user 15.1 ms, sys: 600 µs, total: 15.7 ms
Wall time: 22.1 ms
"""
def dic_mongo(n):
dic = MongoDict()
i=0
while i<n:
dic[i] = "minha Grande String vezes 100"*100
i+=1
def dic_normal(n):
dic = {}
i=0
while i<n:
dic[i] = "minha Grande string vezes 100"*100
i+=1
return dic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment