I consider myself javascript beginner and had a question regarding measuring the performance of JavaScript code. Say I have the below code -
functionA() {
start = performance.now();
// Execute some code.....
functionB();
functionC();
end = performance.now();
console.log(`Time taken: ${end - start}`);
}
Will the calculated time take into account the execution time of both the sub functions?
I thought JavaScript is single threaded and hence, it should be the case. Then I read somewhere that JavaScript Runtime is actually multi threaded, which makes sense because if one part of your code is taking long to execute, it can run other parts of your code in another thread.
If this is indeed true and the above code would not be optimal, is there a way to measure performance which takes into account all the sub functions?