Created
January 19, 2020 19:04
-
-
Save debonx/0ad85daae9bfa7ce5b283817a08eb48a to your computer and use it in GitHub Desktop.
Node: Accessing the process object.
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
let initialMemory = process.memoryUsage().heapUsed; | |
let word = process.argv[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.`) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment