Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let initialMemory = process.memoryUsage().heapUsed;
- let word = process.argv[2]; //the word that user typed begans at index 2
- console.log(`Your word is ${word}`)
- // Create a new array
- let wordArray = [];
- // Loop 1000 times, pushing into the array each time
- for (let i = 0; i < 1000; i++){
- wordArray.push(`${word} count: ${i}`)
- }
- console.log(`Starting memory usage: ${initialMemory}. \nCurrent memory usage: ${process.memoryUsage().heapUsed}. \nAfter using the loop to add elements to the array, the process is using ${process.memoryUsage().heapUsed - initialMemory} more bytes of memory.`)
- /*
- Type in the terminal then enter: node app.js apple
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement