这篇文章需要技术复核。如何帮忙。
我们的志愿者还没有将这篇文章翻译为 中文 (简体)。加入我们帮助完成翻译!
The measure()
method creates a named timestamp
in the browser's performance entry buffer between two specified marks (known as the start mark and end mark, respectively). The named timestamp is referred to as a measure.
The measure
can be retrieved by one of the Performance
interface's getEntries*()
methods (getEntries()
, getEntriesByName()
or getEntriesByType()
).
The measure's
performance entry
will have the following property values:
entryType
- set to "measure
".name
- set to the "name
" given when the measure was created.startTime
- set to thetimestamp
whenmeasure()
was called.duration
- set to aDOMHighResTimeStamp
that is the duration of the measure (typically, the end mark timestamp minus the start mark timestamp).
Syntax
performance.measure(name, startMark, endMark);
Arguments
- name
- A
DOMString
representing the name of the measure. - startMark Optional
- A
DOMString
representing the name of the measure's starting mark. May also be the name of aPerformanceTiming
property. - endMark Optional
- A
DOMString
representing the name of the measure's ending mark. May also be the name of aPerformanceTiming
property.
Return value
- void
Example
The following example shows how measure()
is used to create a new measure performance entry
in the browser's performance entry buffer.
function create_measure(name, markStart, markEnd) { if (performance.measure === undefined) { console.log("performance.measure Not supported"); return; } // Create the performance measure between the two marks performance.measure(name, markStart, markEnd); }
Specifications
Specification | Status | Comment |
---|---|---|
User Timing The definition of 'measure()' in that specification. |
Editor's Draft | Clarifies measure() processing model. |
User Timing The definition of 'measure()' in that specification. |
Recommendation | Basic definition. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic Support | 43.0 | 41 | 10 | 33 | No support |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic Support | No support | 46.0 | 42 | 42 | 10 | 33 | No support | 46.0 |