Created
December 24, 2018 09:17
-
-
Save arrbxr/d7bc00e196354d46335343b474dc9885 to your computer and use it in GitHub Desktop.
performance check of code created by arrbxr - https://repl.it/@arrbxr/performance-check-of-code
This file contains 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 {performance} = require('perf_hooks'); | |
const nemo = ['nemo']; | |
const everyone = ['abhishek', 'pagla', 'ravi', 'raj', 'sita', 'gita', 'ram']; | |
const large = new Array(100000).fill('nemo'); | |
function findNemo(array) { | |
let t0 = performance.now(); | |
for (let i = 0; i < array.length; i++) { | |
if (array[i] === 'nemo') { | |
console.log('Find NEMO!'); | |
} | |
} | |
let t1 = performance.now(); | |
console.log('Call to find NEMO took ' + (t1 - t0) + ' milliseconds'); | |
} | |
findNemo(large); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment