Skip to content

Instantly share code, notes, and snippets.

@erikbeebe
Created September 18, 2012 21:31
Show Gist options
  • Save erikbeebe/3746059 to your computer and use it in GitHub Desktop.
Save erikbeebe/3746059 to your computer and use it in GitHub Desktop.
Sample MongoDB Load Test
loadtest = function () {
db.ortest.drop();
var total_inserts = 5000;
var payload = 16; // payload is a 16 byte string
var a = "";
for (i=1;i<16;i++){a=a+'0123456789ABCDEF'};
start = new Date().getTime();
for (i=1;i<total_inserts;i++){db.ortest.insert({id:i,d:a}); db.getLastError(2)};
end = new Date().getTime();
elapsed = (end - start);
qps = Math.round((total_inserts / (elapsed/1000)));
print("Elapsed Time: " + elapsed + "ms. QPS: " + qps + " inserts/sec");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment