Skip to content Skip to sidebar Skip to footer

Why Does The Execution Time Vary?

I measure execution time like this: function testFn() { return true; } console.time('test'); testFn(); console.timeEnd('test'); Every time I rerun this I get different

Solution 1:

Your browser is also an application that is scheduled by the operating system, so the things that affect the OS also affect the browser.

There could be tons of things affecting the time including internal stuff that your OS kernel is doing like Scheduling processes, flushing file system caches and so on. Unless you are using a real-time operating system. The time duration of execution of your code is not guaranteed.

Post a Comment for "Why Does The Execution Time Vary?"