Skip to content

Instantly share code, notes, and snippets.

@evanshortiss
Last active March 28, 2017 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evanshortiss/b1459582c375217de636daa2ed1671e9 to your computer and use it in GitHub Desktop.
Save evanshortiss/b1459582c375217de636daa2ed1671e9 to your computer and use it in GitHub Desktop.
'use strict';
const mongo = require('rhmap-mongodb');
// First remove anything that might be in the collection
mongo.collection('test').remove({})
.then(doTest);
function doTest () {
let count = 1000;
const start = Date.now();
const promises = [];
while (count) {
promises.push(
mongo.collection('test').insert({
count: count
})
);
count --;
}
Promise.all(promises)
.then(() => {
console.log('test complete in %dms', Date.now() - start);
process.exit(0);
})
.catch((e) => {
console.log('test failed', e.stack);
process.exit(1);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment