#!/bin/bash THREADS=$1 WRITECMD=$2 MULTI=$3 if [ "$4" == "" ]; then BENCH_SECONDS=10 else BENCH_SECONDS=$4 fi # x = benchRun( { ops: [{op: "insert", ns: "test.repro" + threads, doc: {_id: {"#OID":1} } } ], parallel: threads, seconds: '$BENCH_SECONDS', writeCmd: true } ).insert mongo --quiet -eval ' db.repro.drop() threads='$THREADS' singledoc = {x:1} if ("'$MULTI'" == "true") { doc = [] for (i = 0; i < 100; i++) { doc.push(singledoc) } } else { doc = singledoc } ops = [{op: "insert", ns: "test.repro", doc: doc, writeCmd: '$WRITECMD'} ] // command = { "insert": "test.repro", "documents":doc, ordered:false, writeConcern:{ w : 1 } } // ops = [{op: "command", ns: "test.repro", command:command } ] insertsPerSecond = benchRun( { ops: ops, parallel: threads, seconds: '$BENCH_SECONDS' } ).insert if (JSON.stringify(db.repro.findOne({}, {_id:0})) != JSON.stringify(singledoc)) { print("ERROR doc does not match intended:") print(JSON.stringify(db.repro.findOne({}, {_id:0}))) } if( Object.prototype.toString.call( doc ) === "[object Array]" ) { insertsPerSecond *= doc.length } output = threads + ":" + Math.round(insertsPerSecond) + " " + db.repro.count() / '$BENCH_SECONDS' print(output) '