Last active
March 16, 2024 02:22
-
-
Save joaquimnetocel/30de44335fd026291fb4742ce207d401 to your computer and use it in GitHub Desktop.
JAVASCRIPT SPEED TEST
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 numberStartTime = new Date().getTime(); | |
const functionCalculateSolution = function (argA, argB, argC) { | |
const numberDelta = argB * argB - 4 * argA * argC; | |
const numberSolution1 = (-argB + Math.sqrt(numberDelta)) / (2 * argA); | |
const numberSolution2 = (-argB - Math.sqrt(numberDelta)) / (2 * argA); | |
return [numberSolution1, numberSolution2]; | |
}; | |
for (let i = 0; i < 200000000; i++) { | |
functionCalculateSolution(2, 5, 1); | |
} | |
const numberEndTime = new Date().getTime(); | |
const numberTimeSpent = numberEndTime - numberStartTime; | |
console.log(numberTimeSpent / 1000 + " miliseconds."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment