MongoDB性能テストコード
100万件のレコードを書き込み、インデックスを作成し、インデックスを使用して10万回連続してクエリーします.
『10分でMongoDBクラスタを構成する』参照 ,本人のノートパソコン(4 Gメモリ)の性能テストの結果は以下の通りです.
insert begin: Mon Dec 24 2012 15:06:26 GMT+0800 insert End: Mon Dec 24 2012 15:10:14 GMT+0800
find begin: Mon Dec 24 2012 15:10:14 GMT+0800 find end: Mon Dec 24 2012 15:10:37 GMT+0800
およそ1秒あたり400件以上の書き込みがあり、インデックスの作成速度が非常に速く、インデックスを使用して1秒あたり3500件以上のクエリがあります.書くのが遅いのは不思議ではありませんが、普通のノートパソコンにクラスタが付いていますね.
- use admin;//
- db.auth("mongoAdmin","123456");//
- use test;//
- db.test_collection.dropIndexes();
- db.test_collection.drop();
- print("insert begin: "+Date());//
- people = ["Marc", "Bill", "George", "Eliot", "Matt", "Trey", "Tracy", "Greg", "Steve", "Kristina", "Katie", "Jeff"];
- for(var i=10; i<1000000; i++){
- name = people[Math.floor(Math.random()*people.length)];
- user_id = i;
- boolean = [true, false][Math.floor(Math.random()*2)];
- added_at = new Date();
- number = Math.floor(Math.random()*10001);
- db.test_collection1.save({"name":name, "user_id":user_id, "boolean": boolean, "added_at":added_at, "number":number });
- };
- print("insert End: "+Date());//
- db.test_collection.ensureIndex({user_id:1});
- print("find begin: "+Date());//
- var i=0;
- var tempResult=null;
- while(i<100000){
- i=i+1;
- tempResult=db.test_collection.findOne({"user_id":Math.floor(Math.random()*1000000)});
- };
- print("find end: " + Date());//
- print("game over");// ,
『10分でMongoDBクラスタを構成する』参照 ,本人のノートパソコン(4 Gメモリ)の性能テストの結果は以下の通りです.
insert begin: Mon Dec 24 2012 15:06:26 GMT+0800 insert End: Mon Dec 24 2012 15:10:14 GMT+0800
find begin: Mon Dec 24 2012 15:10:14 GMT+0800 find end: Mon Dec 24 2012 15:10:37 GMT+0800
およそ1秒あたり400件以上の書き込みがあり、インデックスの作成速度が非常に速く、インデックスを使用して1秒あたり3500件以上のクエリがあります.書くのが遅いのは不思議ではありませんが、普通のノートパソコンにクラスタが付いていますね.