Skip to content

Instantly share code, notes, and snippets.

@chill-patel
Created July 26, 2018 20:04
Show Gist options
  • Save chill-patel/282fb3e538a35246c6338620dff89bc3 to your computer and use it in GitHub Desktop.
Save chill-patel/282fb3e538a35246c6338620dff89bc3 to your computer and use it in GitHub Desktop.
Node memory test
const q = require('q')
const b = require('bluebird')
const qalllib = require('qalllib')
const used = process.memoryUsage().heapUsed / 1024 / 1024;
console.log(`The Beginning ${Math.round(used * 100) / 100} MB `,);
const add = (num1, num2) => {
return new Promise((resolve, reject ) => {
setTimeout(() => {
resolve(num1+num2)
})
})
}
let allItem = []
for(let i=0; i<=1000000; i++) {
allItem.push(i)
}
function final () {
return qalllib.qASyncWithBatch(add,allItem,50000000,10000000)
.then((res) =>{
console.log(res)
const used = process.memoryUsage().heapUsed / 1024 / 1024;
console.log(`The Ending ${Math.round(used * 100) / 100} MB `,);
})
}
final()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment