diff options
author | clang-format-7.0.1 <adam.martin@10gen.com> | 2019-07-26 18:20:35 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2019-07-27 11:02:23 -0400 |
commit | 134a4083953270e8a11430395357fb70a29047ad (patch) | |
tree | dd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /jstests/core/geo_s2twofields.js | |
parent | 1e46b5049003f427047e723ea5fab15b5a9253ca (diff) | |
download | mongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz |
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/core/geo_s2twofields.js')
-rw-r--r-- | jstests/core/geo_s2twofields.js | 136 |
1 files changed, 67 insertions, 69 deletions
diff --git a/jstests/core/geo_s2twofields.js b/jstests/core/geo_s2twofields.js index c52b5d1d265..c50ca3c46b5 100644 --- a/jstests/core/geo_s2twofields.js +++ b/jstests/core/geo_s2twofields.js @@ -4,85 +4,83 @@ // @tags: [requires_fastcount, operations_longer_than_stepdown_interval_in_txns] (function() { - var t = db.geo_s2twofields; - t.drop(); +var t = db.geo_s2twofields; +t.drop(); - Random.setRandomSeed(); - var random = Random.rand; - var PI = Math.PI; +Random.setRandomSeed(); +var random = Random.rand; +var PI = Math.PI; - function randomCoord(center, minDistDeg, maxDistDeg) { - var dx = random() * (maxDistDeg - minDistDeg) + minDistDeg; - var dy = random() * (maxDistDeg - minDistDeg) + minDistDeg; - return [center[0] + dx, center[1] + dy]; - } +function randomCoord(center, minDistDeg, maxDistDeg) { + var dx = random() * (maxDistDeg - minDistDeg) + minDistDeg; + var dy = random() * (maxDistDeg - minDistDeg) + minDistDeg; + return [center[0] + dx, center[1] + dy]; +} - var nyc = {type: "Point", coordinates: [-74.0064, 40.7142]}; - var miami = {type: "Point", coordinates: [-80.1303, 25.7903]}; - var maxPoints = 10000; - var degrees = 5; +var nyc = {type: "Point", coordinates: [-74.0064, 40.7142]}; +var miami = {type: "Point", coordinates: [-80.1303, 25.7903]}; +var maxPoints = 10000; +var degrees = 5; - var arr = []; - for (var i = 0; i < maxPoints; ++i) { - var fromCoord = randomCoord(nyc.coordinates, 0, degrees); - var toCoord = randomCoord(miami.coordinates, 0, degrees); +var arr = []; +for (var i = 0; i < maxPoints; ++i) { + var fromCoord = randomCoord(nyc.coordinates, 0, degrees); + var toCoord = randomCoord(miami.coordinates, 0, degrees); - arr.push({ - from: {type: "Point", coordinates: fromCoord}, - to: {type: "Point", coordinates: toCoord} - }); - } - res = t.insert(arr); - assert.writeOK(res); - assert.eq(t.count(), maxPoints); + arr.push( + {from: {type: "Point", coordinates: fromCoord}, to: {type: "Point", coordinates: toCoord}}); +} +res = t.insert(arr); +assert.writeOK(res); +assert.eq(t.count(), maxPoints); - function semiRigorousTime(func) { - var lowestTime = func(); - var iter = 2; - for (var i = 0; i < iter; ++i) { - var run = func(); - if (run < lowestTime) { - lowestTime = run; - } +function semiRigorousTime(func) { + var lowestTime = func(); + var iter = 2; + for (var i = 0; i < iter; ++i) { + var run = func(); + if (run < lowestTime) { + lowestTime = run; } - return lowestTime; - } - - function timeWithoutAndWithAnIndex(index, query) { - t.dropIndex(index); - var withoutTime = semiRigorousTime(function() { - return t.find(query).explain("executionStats").executionStats.executionTimeMillis; - }); - t.ensureIndex(index); - var withTime = semiRigorousTime(function() { - return t.find(query).explain("executionStats").executionStats.executionTimeMillis; - }); - t.dropIndex(index); - return [withoutTime, withTime]; } + return lowestTime; +} - var maxQueryRad = 0.5 * PI / 180.0; - // When we're not looking at ALL the data, anything indexed should beat not-indexed. - var smallQuery = timeWithoutAndWithAnIndex({to: "2dsphere", from: "2dsphere"}, { - from: {$within: {$centerSphere: [nyc.coordinates, maxQueryRad]}}, - to: {$within: {$centerSphere: [miami.coordinates, maxQueryRad]}} +function timeWithoutAndWithAnIndex(index, query) { + t.dropIndex(index); + var withoutTime = semiRigorousTime(function() { + return t.find(query).explain("executionStats").executionStats.executionTimeMillis; }); - print("Indexed time " + smallQuery[1] + " unindexed " + smallQuery[0]); - // assert(smallQuery[0] > smallQuery[1]); - - // Let's just index one field. - var smallQuery = timeWithoutAndWithAnIndex({to: "2dsphere"}, { - from: {$within: {$centerSphere: [nyc.coordinates, maxQueryRad]}}, - to: {$within: {$centerSphere: [miami.coordinates, maxQueryRad]}} + t.ensureIndex(index); + var withTime = semiRigorousTime(function() { + return t.find(query).explain("executionStats").executionStats.executionTimeMillis; }); - print("Indexed time " + smallQuery[1] + " unindexed " + smallQuery[0]); - // assert(smallQuery[0] > smallQuery[1]); + t.dropIndex(index); + return [withoutTime, withTime]; +} - // And the other one. - var smallQuery = timeWithoutAndWithAnIndex({from: "2dsphere"}, { - from: {$within: {$centerSphere: [nyc.coordinates, maxQueryRad]}}, - to: {$within: {$centerSphere: [miami.coordinates, maxQueryRad]}} - }); - print("Indexed time " + smallQuery[1] + " unindexed " + smallQuery[0]); - // assert(smallQuery[0] > smallQuery[1]); +var maxQueryRad = 0.5 * PI / 180.0; +// When we're not looking at ALL the data, anything indexed should beat not-indexed. +var smallQuery = timeWithoutAndWithAnIndex({to: "2dsphere", from: "2dsphere"}, { + from: {$within: {$centerSphere: [nyc.coordinates, maxQueryRad]}}, + to: {$within: {$centerSphere: [miami.coordinates, maxQueryRad]}} +}); +print("Indexed time " + smallQuery[1] + " unindexed " + smallQuery[0]); +// assert(smallQuery[0] > smallQuery[1]); + +// Let's just index one field. +var smallQuery = timeWithoutAndWithAnIndex({to: "2dsphere"}, { + from: {$within: {$centerSphere: [nyc.coordinates, maxQueryRad]}}, + to: {$within: {$centerSphere: [miami.coordinates, maxQueryRad]}} +}); +print("Indexed time " + smallQuery[1] + " unindexed " + smallQuery[0]); +// assert(smallQuery[0] > smallQuery[1]); + +// And the other one. +var smallQuery = timeWithoutAndWithAnIndex({from: "2dsphere"}, { + from: {$within: {$centerSphere: [nyc.coordinates, maxQueryRad]}}, + to: {$within: {$centerSphere: [miami.coordinates, maxQueryRad]}} +}); +print("Indexed time " + smallQuery[1] + " unindexed " + smallQuery[0]); +// assert(smallQuery[0] > smallQuery[1]); }()); |