[iyunv@h3 home]# mongod -f /etc/mongod.conf
Thu Jul 25 00:19:15.950
Thu Jul 25 00:19:15.950 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Thu Jul 25 00:19:15.950
about to fork child process, waiting until server is ready for connections.
forked process: 14519
all output going to: /var/log/mongo/mongod.log
child process started successfully, parent exiting
[iyunv@h3 home]#
实验第二步,编辑测试文件,这里我们保存为test.py,文件内容如下:
#!usr/bin/python
#coding=utf-8
from pymongo import Connection
import time
db = Connection().performance_test
db.drop_collection("updates")
collection = db.updates
collection.insert({"x": 1})
collection.find_one()
# in inc test
start_inc = time.time()
for i in range(100000):
collection.update({}, {"$inc" : {"x" : 1}})
collection.find_one()
print '$inc:', time.time() - start_inc
# in set test
start_set = time.time()
for i in range(100000):
collection.update({}, {"$set" : {"x" : 1}})
collection.find_one()
print '$set:', time.time() - start_set
# in push test
start_push = time.time()
for i in range(100000):
collection.update({}, {"$push" : {"x" : 1}})
collection.find_one()
print '$push:', time.time() - start_push