diff options
author | Aaron <aaron@10gen.com> | 2009-02-26 17:32:52 -0500 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2009-02-26 17:32:52 -0500 |
commit | c61536f8c239639be25088935b4a534caa155704 (patch) | |
tree | e3a1ab2d80205776fc44210cb75a4fa834b85edc /jstests/perf | |
parent | 81f394da6130757fc048a2e669338ee0ba8c3496 (diff) | |
download | mongo-c61536f8c239639be25088935b4a534caa155704.tar.gz |
Add updated version of remove1.js test grabbed from ed
Diffstat (limited to 'jstests/perf')
-rw-r--r-- | jstests/perf/remove1.js | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/jstests/perf/remove1.js b/jstests/perf/remove1.js new file mode 100644 index 00000000000..67aa7a92dcb --- /dev/null +++ b/jstests/perf/remove1.js @@ -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); |