Created
September 20, 2013 18:15
-
-
Save acmorrow/6641558 to your computer and use it in GitHub Desktop.
Expanded update benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var numDatabases = 3; | |
var numDocumentsPerCollection = 5; | |
var collections = []; | |
for ( var i=0; i<numDatabases; i++ ) { | |
collections.push( db.getSisterDB("mms" + i).things ); | |
} | |
var base = { a : 0, h : {}, z : 0 }; | |
for ( h=0; h<24; h++ ) { | |
base.h[h] = {}; | |
for ( min=0; min<60; min++ ) { | |
base.h[h][min] = { n : 0 , t : 0, z : 0 }; | |
} | |
} | |
var updates = [ | |
{ $inc : { a : 1 } }, | |
{ $inc : { a : 1, z : 1 } }, | |
{ $inc : { "h.23.59.n" : 1 } }, | |
{ $inc : { "h.23.59.n" : 1 , "h.23.59.t" : 5 } }, | |
{ $inc : { "h.23.59.n" : 1 , "h.23.59.t" : 5, "h.23.59.z" : 10 } }, | |
{ $inc : { "h.22.59.n" : 1 , "h.23.59.t" : 5 } }, | |
{ $inc : { "h.21.59.n" : 1 , "h.22.59.t" : 5, "h.23.59.z" : 10 } }, | |
{ $set : { a : 0 } }, | |
{ $set : { "h.23.59.n" : 0 } }, | |
] | |
for( var u=0; u < updates.length; u++ ) { | |
var ops = []; | |
for ( var i=0; i<collections.length; i++ ) { | |
var t = collections[i]; | |
t.drop(); | |
} | |
for ( var i=0; i<collections.length; i++ ) { | |
var t = collections[i]; | |
if ( t.count() != numDocumentsPerCollection ) { | |
// drop | |
t.drop(); | |
// insert docs | |
for ( var j=0; j<numDocumentsPerCollection; j++ ) { | |
base._id = j; | |
t.insert( base ); | |
} | |
t.getDB().getLastError(); | |
} | |
// set up ops for load | |
ops.push( { op : "update" , | |
ns : t.getFullName() , | |
query : { _id : { "#RAND_INT" : [ 0 , numDocumentsPerCollection ] } } , | |
update : updates[u], | |
} ); | |
} | |
var threads = [ 20 ]; | |
for ( var i=0; i<threads.length; i++ ) { | |
var res = benchRun( { ops : ops , seconds : 30 , parallel : threads[i] , host : db.getMongo().host } ); | |
print( threads[i] + "\t" + res.update ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment