2. The Performance interface provides access to
performance-related information for the
current page.
Performance.now()
Returns a DOMHighResTimeStamp;
//The time, given in milliseconds, should be
accurate to 5 µs (microseconds), with the
fractional part of the number indicating
fractions of a millisecond.
Performance.mark()
Creates a timestamp in the browser's performance
entry buffer with the given name.
Syntax: performance.mark(name);
3. Performance.measure()
Creates a named timestamp in the browser's
performance entry buffer between two specified
marks (known as the start mark and end mark,
respectively).
Syntax: performance.measure(name, startMark,
endMark);
Performance.clearMeasures()
Performance.clearMarks()
Removes the given mark from the browser's
performance entry buffer.
Removes the given measure from the browser's
performance entry buffer.
4. Performance.getEntries()
Returns a list of PerformanceEntry objects based
on the given filter.
Performance.getEntriesByType()
Performance.getEntriesByName()
Returns a list of PerformanceEntry objects based
on the given name and entry type.
The getEntriesByType() method returns a list of
PerformanceEntry objects for a given type.
Continued in next slide
5. function measurePerformance() {
Performance.mark('FUNCTION_START');
// Do Some Operation
Performance.mark('FUNCTION_END');
Performance.measure('FUNCTION_PERFROMANCE'
, 'FUNCTION_START', 'FUNCTION_END');
console.log(Performance.getEntries());
console.log(Performance.getEntriesByName('
FUNCTION_PERFROMANCE'));
console.log(Performance.getEntriesByType('
measure'));
Performance.clearMarks();
Performance.clearMeasures();
}
6. Delivered with ❤ by Ideas2IT in
collaboration with
We deliver bite-sized JavaScript
microlearning modules for busy tech
developers. Nuggets of tips, news, resources
& curated content are delivered regularly.
Stay tuned to learn the nuances of JS😎
JS NUGGETS