Javascript Methods from Performance Timeline API | Hacker Noon

Author profile picture

@mozillaMozilla Contributors

Mozilla (stylized as moz://a) is a free software community founded in 1998 by members of Netscape.

The Performance Timeline API defines extensions to the

Performance

interface to support client-side latency measurements within applications. The extensions provide interfaces to retrieve performance entry metrics based on specific filter criteria. The standard also includes interfaces that allow an application to define performance observer callbacks that are notified when specific performance events are added to the browser’s performance timeline.

This document provides an overview of the standard’s interfaces. For
more details about the interfaces, see the reference pages and Using Performance Timeline.

Performance extensions

The Performance Timeline API extends the

Performance

interface with three methods that provide different mechanisms to get a set of

performance records (metrics)

, depending on the specified filter criteria. The methods are:

PerformanceEntry interface

The

PerformanceEntry

interface encapsulates a single performance entry — that is, a single data point or metric in the performance timeline. This interface has the following four properties, and these properties are extended (with additional constraints) by other interfaces (such as

PerformanceMark

):

The name of the performance entry when the metric was created.

The type of performance metric (for example, ”

mark

“).

A high resolution timestamp representing the time value of the duration of the performance event. (Some performance entry types have no concept of duration and this value is set to ‘

0

‘ for such types.)

This interface includes a

toJSON()

method that returns the serialization of the

PerformanceEntry

object. The serialization is specific to the performance entry’s

type

.

Performance observers

This is an

experimental technology
Check the Browser compatibility table carefully before using this in production.

The performance observer interfaces allow an application to register an observer for specific performance event types, and when one of those event types is recorded, the application is notified of the event via the observer’s callback function that was specified when the observer was created.

Performance observers were added to the Level 2 version of the standard and were not widely implemented.

Implementation status

A summary of the interfaces’ implementation status is provided below, including a link to more detailed information.

To test your browser’s support for these interfaces, run the

perf-api-support

application.

See Also

Credits

Author profile picture

Read my stories

Mozilla (stylized as moz://a) is a free software community founded in 1998 by members of Netscape.

Comments

Tags

The Noonification banner

Subscribe to get your daily round-up of top tech stories!

read original article here