Skip to content
Advertisement

How to benchmark a function in VueJs Store?

I have the following script in my VueJs2 Store Config, and I suspect that the if statement below is causing extra load, even if not triggered, but I’m unsure:

JavaScript

Being new to testing in JS in general, I would like to hear suggestions as to the best methods of benchmarking and debugging this further, any tips appreciated.

Full function:

JavaScript

Advertisement

Answer

You can measure time of the execution of any block of code with:

JavaScript

And you will got console output like: some measure: 0.0126953125 ms You just need to put you code between time and timeEnd calls.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement