Skip to content

Instantly share code, notes, and snippets.

@joaquimnetocel
Last active March 16, 2024 02:22
Show Gist options
  • Save joaquimnetocel/30de44335fd026291fb4742ce207d401 to your computer and use it in GitHub Desktop.
Save joaquimnetocel/30de44335fd026291fb4742ce207d401 to your computer and use it in GitHub Desktop.
JAVASCRIPT SPEED TEST
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