Created
March 9, 2020 15:51
-
-
Save oleh-zaporozhets/65b5222a3f8bdaae604a6c32bada2a69 to your computer and use it in GitHub Desktop.
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
const fs = require('fs'); | |
const str = fs.readFileSync('./str.txt', 'utf8'); | |
console.log('String length:', str.length); | |
console.log('---------'); | |
function test() { | |
console.time('Call speed'); | |
const res = Array.prototype.join.call(str, ' '); | |
const used = process.memoryUsage().heapUsed / 1024 / 1024; | |
console.log(`Call uses approximately ${Math.round(used * 100) / 100} MB`); | |
console.timeEnd('Call speed'); | |
console.log('---------'); | |
} | |
for (let index = 0; index < 10; index++) { | |
test(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment