I was messing around with JavaScript, and I wanted to do something I have never done before.
I looked up various things online, wondering how fast a function calls.
I found this code:
var performance = window.performance;
var t0 = performance.now();
doWork();
var t1 = performance.now();
console.log("Call to doWork took " + (t1 - t0) + " milliseconds.")
I personally loved this code, because it runs the function automatically, and it is easy to set up because all you have to do is change doWork(); to your function, and put the code under the function.
I did something where I logged "Hi" to the console, from a function and got many different times for the function to be running.
Almost like human reaction times, each time it calls the function, a variable amount of time is required to run the function.
It is completely random, and it is running the same function over and over again. Here is my full JavaScript code:
function hi() {
console.log("Hi")
}
var performance = window.performance;
var t0 = performance.now();
hi();
var t1 = performance.now();
console.log("Call to function took " + (t1 - t0) + " milliseconds.")
Can anyone explain why it calls at completely different times?