W3C User Timing API’s – The W3C User Timing API is typically used in conjunction with W3C Navigation Timing API. The Navigation Timing API obtains exact latency measurements from the browser. You can read about it here http://www.w3.org/TR/navigation-timing/. It will measure all tasks of a page load such as redirection, app cache, DNS, TCP, request, response, processing, onLoad, unload.
To very simply explain how you use the marks and measures, you put a begin mark at the beginning of the code you wish to measure, and end and measure marks at the end of the code you wish to measure. Here’s an example:
… your code …
Reporting on timing results – So now that we have the ability to easily capture our timings, how do we report on them? There are a couple of options. We can log the results to a log file. The positive about this method is that it is easy and requires no setup. The negative is that it will be difficult to analyze the results. Another option is to stream the results to a database. This, however will require database setup and code must be written to stream the data. However, once the timing results are in a database, they can be analyzed with the use of queries.