Member-only story
The right way to measure your JS performances
Two ways of measuring your application performance and when to use them
Introduction
Measuring performance is an important part of delivering a good experience for the user and keeping an eye on potential bottlenecks.
There are multiple ways to measure the performance of your application and they depend on the objective that you have.
This article is using only vanilla Javascript and is not talking about potential external libraries
Analytics
The first objective could be for analytic purposes. You’re having an application running in production and you would like to keep an eye on the duration of specific operations by logging those results into a database.
To do so, we can use a module called Performance
.
How does it work
Performance is a pretty straightforward module to use.
It doesn’t need any import as it’s embedded in JS. It also works on most recent browsers and recent versions of NodeJS.
You first of all need to mark the beginning and end of your operation.
To do so, you can use performance.mark("markName")
at the beginning and at the…