summaryrefslogtreecommitdiff
path: root/jstests/perf/v8_mapreduce.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/perf/v8_mapreduce.js')
-rw-r--r--jstests/perf/v8_mapreduce.js35
1 files changed, 19 insertions, 16 deletions
diff --git a/jstests/perf/v8_mapreduce.js b/jstests/perf/v8_mapreduce.js
index b98cdc5fc0d..7ff329c5284 100644
--- a/jstests/perf/v8_mapreduce.js
+++ b/jstests/perf/v8_mapreduce.js
@@ -2,20 +2,21 @@
// Our server and client need to be running V8 and the host we are running on needs at least two
// cores. Update this if you are testing more than three threads in parallel.
-if (/V8/.test(interpreterVersion()) &&
- db.runCommand({buildinfo:1}).javascriptEngine == "V8" &&
+if (/V8/.test(interpreterVersion()) && db.runCommand({buildinfo: 1}).javascriptEngine == "V8" &&
db.hostInfo().system.numCores >= 2) {
-
// function timeSingleThread
// Description: Gathers data about how long it takes to run a given job
// Args: job - job to run
// tid - thread id passed as an argument to the job, default 0
// Returns: { threadStart : <time job started> , threadEnd : <time job completed> }
- var timeSingleThread = function (job, tid) {
+ var timeSingleThread = function(job, tid) {
var tid = tid || 0;
var threadStart = new Date();
job(tid);
- return { "threadStart" : threadStart , "threadEnd" : new Date() };
+ return {
+ "threadStart": threadStart,
+ "threadEnd": new Date()
+ };
};
// function timeMultipleThreads
@@ -28,7 +29,7 @@ if (/V8/.test(interpreterVersion()) &&
// threadEnd : <time elapsed before thread completed work> } ,
// ...
// ]
- var timeMultipleThreads = function (job, nthreads, stagger) {
+ var timeMultipleThreads = function(job, nthreads, stagger) {
var i = 0;
var threads = [];
@@ -59,7 +60,7 @@ if (/V8/.test(interpreterVersion()) &&
// Display and analysis helper functions
- var getLastCompletion = function (threadTimes) {
+ var getLastCompletion = function(threadTimes) {
var lastCompletion = 0;
for (var i = 0; i < threadTimes.length; i++) {
lastCompletion = Math.max(lastCompletion, threadTimes[i].threadEnd);
@@ -71,14 +72,17 @@ if (/V8/.test(interpreterVersion()) &&
db.v8_parallel_mr_src.drop();
- for (j=0; j<100; j++) for (i=0; i<512; i++){ db.v8_parallel_mr_src.save({j:j, i:i});}
+ for (j = 0; j < 100; j++)
+ for (i = 0; i < 512; i++) {
+ db.v8_parallel_mr_src.save({j: j, i: i});
+ }
db.getLastError();
- var mrWorkFunction = function () {
+ var mrWorkFunction = function() {
function verifyOutput(out) {
- //printjson(out);
+ // printjson(out);
assert.eq(out.counts.input, 51200, "input count is wrong");
assert.eq(out.counts.emit, 51200, "emit count is wrong");
assert.gt(out.counts.reduce, 99, "reduce count is wrong");
@@ -87,22 +91,21 @@ if (/V8/.test(interpreterVersion()) &&
function map() {
if (this.j % 2 == 0) {
- emit(this.i, this.j*this.j);
- }
- else {
- emit(this.i, this.j+this.j);
+ emit(this.i, this.j * this.j);
+ } else {
+ emit(this.i, this.j + this.j);
}
}
function reduce(key, values) {
- values_halved = values.map(function (value) {
+ values_halved = values.map(function(value) {
return value / 2;
});
values_halved_sum = Array.sum(values_halved);
return values_halved_sum;
}
- var out = db.v8_parallel_mr_src.mapReduce(map, reduce, { out : "v8_parallel_mr_out" });
+ var out = db.v8_parallel_mr_src.mapReduce(map, reduce, {out: "v8_parallel_mr_out"});
verifyOutput(out);
};