0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00

Add updated version of remove1.js test grabbed from ed

This commit is contained in:
Aaron 2009-02-26 17:32:52 -05:00
parent 81f394da61
commit c61536f8c2

70
jstests/perf/remove1.js Normal file
View File

@ -0,0 +1,70 @@
/**
* Performance tests for removing ojects
*/
var removals = 100;
var size = 500000;
var collection_name = "remove_test";
var msg = "Hello from remove test";
function testSetup(dbConn) {
var t = dbConn[collection_name];
t.drop();
t.ensureIndex( { num : 1 } );
for (var i=0; i<size; i++){
t.save({ num : i, msg : msg });
}
}
function between( low, high, val, msg ) {
assert( low < val, msg );
assert( val < high, msg );
}
/**
* Compares difference of removing objects from a collection if only includes
* field that's indexed, vs w/ additional other fields
*
* @param dbConn
*/
function testRemoveWithMultiField(dbConn) {
var results = {};
var t = dbConn[collection_name];
testSetup(dbConn);
t.remove( {num:0 } );
results.indexOnly = Date.timeFunc(
function(){
for (var i = 1; i < removals; i++) {
t.remove({num : i});
}
t.findOne();
}
);
testSetup(dbConn);
t.remove( {num: 0, msg: msg } );
results.withAnother = Date.timeFunc(
function(){
for (var i = 1; i < removals; i++) {
t.remove({num : i, msg : msg});
}
t.findOne();
}
);
between( 0.65, 1.35, (results.indexOnly / results.withAnother),
"indexOnly / withAnother (" + results.indexOnly + " / " + results.withAnother + " ) = " +
results.indexOnly / results.withAnother + " not in [0.65, 1.35]" );
}
var db = connect( "ed_perf_remove1" );
testRemoveWithMultiField(db);