I made a video of how to use console.time() to compare two JS functions. Specifically I compared two Chunky Monkey codes, the beginner and intermediate solutions. The comparison was done in FireFox.
The result? The beginner solution outperformed the intermediate solution in execution time. However, the two execution time data sets are not statistically different from one another. I did a t-test on them and at 95% confidence, the data sets are not statistically different. Here is the LibreOffice Calc data below.
Comments: Yeah, the two codes are just going to execute instantaneously for the average user, so why do this? I wanted to find a way to compare two codes and statistically compare them for when codes are more complex and will need to be compared for speed.
The p-value of 0.41 is outside my confidence interval (p value must be <.05 for the two distributions to be unique and not just a result of chance). So “according to the books,” the difference in average could be the result of random chance.
Also, please let me know if there’s a better way to find the performance of a JS script. The video is not great and the mic is awful lol. And it has a lot of mistakes. It is my first desktop vid so I figured what the hey, I’m not gonna try that hard…
I hope you all got something out of the video and stats! Happy coding.