summaryrefslogtreecommitdiff
path: root/jstests/core/bench_test2.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/bench_test2.js')
-rw-r--r--jstests/core/bench_test2.js54
1 files changed, 27 insertions, 27 deletions
diff --git a/jstests/core/bench_test2.js b/jstests/core/bench_test2.js
index c2e3881632c..072686348e4 100644
--- a/jstests/core/bench_test2.js
+++ b/jstests/core/bench_test2.js
@@ -2,16 +2,20 @@
t = db.bench_test2;
t.drop();
-for ( i=0; i<100; i++ )
- t.insert( { _id : i , x : 0 } );
-
-benchArgs = { ops : [ { ns : t.getFullName() ,
- op : "update" ,
- query : { _id : { "#RAND_INT" : [ 0 , 100 ] } } ,
- update : { $inc : { x : 1 } } } ] ,
- parallel : 2 ,
- seconds : 1 ,
- host : db.getMongo().host };
+for (i = 0; i < 100; i++)
+ t.insert({_id: i, x: 0});
+
+benchArgs = {
+ ops: [{
+ ns: t.getFullName(),
+ op: "update",
+ query: {_id: {"#RAND_INT": [0, 100]}},
+ update: {$inc: {x: 1}}
+ }],
+ parallel: 2,
+ seconds: 1,
+ host: db.getMongo().host
+};
if (jsTest.options().auth) {
benchArgs['db'] = 'admin';
@@ -19,29 +23,25 @@ if (jsTest.options().auth) {
benchArgs['password'] = jsTest.options().adminPassword;
}
-res = benchRun( benchArgs );
-printjson( res );
+res = benchRun(benchArgs);
+printjson(res);
sumsq = 0;
sum = 0;
min = 1000;
max = 0;
-t.find().forEach(
- function(z){
- sum += z.x;
- sumsq += Math.pow( ( res.update / 100 ) - z.x , 2 );
- min = Math.min( z.x , min );
- max = Math.max( z.x , max );
- }
-);
+t.find().forEach(function(z) {
+ sum += z.x;
+ sumsq += Math.pow((res.update / 100) - z.x, 2);
+ min = Math.min(z.x, min);
+ max = Math.max(z.x, max);
+});
avg = sum / 100;
-std = Math.sqrt( sumsq / 100 );
-
-print( "Avg: " + avg );
-print( "Std: " + std );
-print( "Min: " + min );
-print( "Max: " + max );
-
+std = Math.sqrt(sumsq / 100);
+print("Avg: " + avg);
+print("Std: " + std);
+print("Min: " + min);
+print("Max: " + max);