Created
September 18, 2012 21:31
-
-
Save erikbeebe/3746059 to your computer and use it in GitHub Desktop.
Sample MongoDB Load Test
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
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