测试mongodb的插入性能
2011-09-21 09:50
134 查看
#coding:utf-8 """ 用于测试mongodb的插入性能 起4个进程 每个进程起25个线程 每个线程做9000次插入操作 计算消耗的时间 """ import pymongo from multiprocessing import Process from time import ctime,sleep from threading import Thread import os conn = pymongo.Connection() #测试一下 #collection.insert({'uid':'00011','uname':'qinxiuchen','udescription':'he is a man who come from elex and gratitute from buaa'}) #re = collection.find_one() #print re #进程方法 def processFun(): import multiprocessing #起25个线程 tList = [] for i in range(0,25): t = Thread(target=threadFun, args=(os.getpid(),)) tList.append(t) for t in tList: t.start() for t in tList: t.join() pass #线程方法 def threadFun(pid): collection = conn.test.testinsert for i in range(0, 50000): collection.insert({'uid':str(pid)+str(i),'uname':'qinxiuchen','udescription':'he is a man who come from elex and gratitute from buaa'}) pass if __name__ == '__main__': pList = [] print 'start main process at:',ctime() for i in range(0,4): p = Process(target=processFun, args=()) pList.append(p) p.start() for p in pList: p.join() print 'end main process at:',ctime()
采用非安全模式。
随着插入条目的增多,消耗时间基本呈线性增长,若选择每个线程插入50000条数据共消耗100s。
其他测试还有待继续。
相关文章推荐
- MongoDB与MySQL的插入、查询性能测试
- MongoDB与MySQL的插入性能测试
- MongoDB与MySQL的插入、查询性能测试
- MongoDB与MySQL的插入、查询性能测试
- 运行Delphi XE10的MongoDB例程,测试Delphi插入记录性能
- 【MongoDb】一次关于Oracle和MongoDb的插入和查询性能测试
- MongoDB与MySQL的插入、查询性能测试
- MongoDB与MySQL的插入、查询性能测试
- MongoDB与MySQL的插入、查询性能测试
- MongoDB与MySQL的插入性能测试【转】
- MongoDB与MySQL的插入、查询性能测试
- MongoDB与MySQL的插入、查询性能测试
- MyISAM和InnoDB的插入性能测试
- Mongodb亿级数据量的性能测试
- mongodb3.0 性能测试报告 二
- MongoDB,Redis,Tokyo Tyrant(Tokyo Cabinet)性能测试比较
- [原创]MongoDB、HandlerSocket和MySQL性能测试及其结果分析
- 【转载】MongoDB 1000W级数据 Insert和Query和Delete性能测试
- mongdb性能压力测试,随机查询,数据量1亿条记录 操作系统centos6.4x64位 从测试结果看,当mongodb将数据全部载入到内存后,查询速度根据文档的大小,性能瓶颈通常会是在网络流