您好,欢迎来到微智科技网。
搜索
您的当前位置:首页MongoDB性能测试与Python测试代码

MongoDB性能测试与Python测试代码

来源:微智科技网


下面是对mongodb测试的代码和结果。虽然公司用的一水的CentOS,但是由于我是FreeBSD的支持者,所以在FreeBSD和CentOS上都测试了一

#!/usr/bin/env python

from pymongo import Connection
import time,datetime

connection = Connection('127.0.0.1', 27017)
db = connection['hawaii']

def func_time(func):
def _wrapper(*args,**kwargs):
start = time.time()
func(*args,**kwargs)
print func.__name__,'run:',time.time()-start
return _wrapper

@func_time
def remove():
posts = db.userinfo
print 'count before remove:',posts.count();
posts.remove({});
print 'count after remove:',posts.count();

if __name__ == "__main__":
remove()

Copyright © 2019- 7swz.com 版权所有 赣ICP备2024042798号-8

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务