Skip to content

Instantly share code, notes, and snippets.

@arrbxr
Created December 24, 2018 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arrbxr/d7bc00e196354d46335343b474dc9885 to your computer and use it in GitHub Desktop.
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
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