diff options
author | Aaron <aaron@10gen.com> | 2009-02-26 17:01:56 -0500 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2009-02-26 17:01:56 -0500 |
commit | 81f394da6130757fc048a2e669338ee0ba8c3496 (patch) | |
tree | 6ca21a8c152dda80cd0ccfbe76f0da0ef36e51ae /jstests/perf | |
parent | 18c7965db4c67ff00eb8ac9d93db078c59aee22e (diff) | |
download | mongo-81f394da6130757fc048a2e669338ee0ba8c3496.tar.gz |
Fix find1.js test
Diffstat (limited to 'jstests/perf')
-rw-r--r-- | jstests/perf/find1.js | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/jstests/perf/find1.js b/jstests/perf/find1.js index 59f53296893..82d518fe524 100644 --- a/jstests/perf/find1.js +++ b/jstests/perf/find1.js @@ -17,6 +17,16 @@ function testSetup(dbConn) { } } +function resetQueryCache( db ) { + db[ collection_name ].createIndex( { a: 1 }, "dumbIndex" ); + db[ collection_name ].dropIndex( "dumbIndex" ); +} + +function between( low, high, val, msg ) { + assert( low < val, msg ); + assert( val < high, msg ); +} + /** * Tests fetching a set of 10 objects in sorted order, comparing getting * from front of collection vs end, using $lt @@ -26,18 +36,20 @@ function testFindLTFrontBack(dbConn) { var results = {}; var t = dbConn[collection_name]; + resetQueryCache( dbConn ); results.oneInOrderLTFirst = Date.timeFunc( function(){ assert( t.find( { num : {$lt : 20} } ).sort( { num : 1 } ).limit(10).toArray().length == 10); } , calls ); + resetQueryCache( dbConn ); results.oneInOrderLTLast = Date.timeFunc( function(){ assert( t.find( { num : {$lt : size-20 }} ).sort( { num : 1 } ).limit(10).toArray().length == 10); } , calls ); - assert( 0.9 < (results.oneInOrderLTFirst / results.oneInOrderLTLast) < 1.1, + between( 0.9, 1.1, results.oneInOrderLTFirst / results.oneInOrderLTLast, "first / last (" + results.oneInOrderLTFirst + " / " + results.oneInOrderLTLast + " ) = " + results.oneInOrderLTFirst / results.oneInOrderLTLast + " not in [0.9, 1.1]" ); } @@ -53,18 +65,20 @@ function testFindGTFrontBack(dbConn) { var results = {}; var t = dbConn[collection_name]; + resetQueryCache( dbConn ); results.oneInOrderGTFirst = Date.timeFunc( function(){ assert( t.find( { num : {$gt : 5} } ).sort( { num : 1 } ).limit(10).toArray().length == 10); } , calls ); + resetQueryCache( dbConn ); results.oneInOrderGTLast = Date.timeFunc( function(){ assert( t.find( { num : {$gt : size-20 }} ).sort( { num : 1 } ).limit(10).toArray().length == 10); } , calls ); - assert( 0.25 < (results.oneInOrderGTFirst / results.oneInOrderGTLast) < 4.0, + between( 0.25, 4.0, results.oneInOrderGTFirst / results.oneInOrderGTLast, "first / last (" + results.oneInOrderGTFirst + " / " + results.oneInOrderGTLast + " ) = " + results.oneInOrderGTFirst / results.oneInOrderGTLast + " not in [0.25, 4.0]" ); |