Last active
February 1, 2022 19:44
-
-
Save cicconewk/c281d852c30496b71ac3b980c21fa8c2 to your computer and use it in GitHub Desktop.
It's the first attempt to test the performance of a function that given an array will return a certain value.
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 nemo = ["nemo"]; | |
function findNemo(array) { | |
let t0 = performance.now(); | |
for (let i = 0; i < array.lenght; i++) { | |
if (array[i] === "nemo") { | |
console.log("Found NEMO!"); | |
} | |
} | |
let t1 = performance.now(); | |
console.log(`Call to find Nemo took ${t1 - t0} milliseconds`); | |
} | |
findNemo(nemo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment