Python_mongodb計算增加刪除速度

 

  1. #! /user/bin/env python 
  2.  
  3.  
  4. from pymongo import Connection 
  5.  
  6. db = Connection().foo 
  7. collection = db.bar 
  8.  
  9. for i in range(10000000): 
  10.     collection.insert({"foo" : "bar""baz" : i, "z" : 10 - i}) 
  11.  
  12. import time 
  13. start = time.time() 
  14.  
  15. collection.remove() 
  16. collection.find_one() 
  17.  
  18. total = time.time() - start 
  19.  
  20. print "%d seconds" % total 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章