PerformanceResourceTiming

这篇翻译不完整。请帮忙从英语翻译这篇文章

PerformanceResourceTiming接口可以检索和分析有关加载应用程序资源的详细网络计时数据。 应用程序可以使用timing指标来确定获取特定资源所需的时间长度,例如XMLHttpRequest<SVG>,image或script。
这个接口使用high-resolution timestamps 属性创建加载资源时间轴,用于网络事件,例如重定向开始( redirect start )和结束时间,获取开始( fetch start ),DNS查找开始( DNS lookup start )和结束时间,响应开始( response start )和结束时间等。此外,接口扩展PerformanceEntry与其他属性,这些属性提供有关获取资源大小的数据以及初始化时获取的资源类型。
Note: 此特性在 Web Worker 中可用。

属性

此接口通过限定和约束PerformanceEntry属性来扩展资源性能条目类型,如下所示:

 PerformanceEntry.entryType只读
返回 "resource".
PerformanceEntry.name只读
返回 resources URL.
PerformanceEntry.startTime只读
在资源提取开始的时间返回timestamp。 该值等于PerformanceEntry.fetchStart
PerformanceEntry.duration只读
返回timestamp,它是responseEndstartTime属性之间的差异。

该接口还支持以下属性,这些属性按记录顺序列出以获取单个资源。 按字母顺序排列的列表显示在左侧的导航栏中。

PerformanceResourceTiming.initiatorType只读
返回string,表示初始化性能条目的资源类型,如PerformanceResourceTiming.initiatorType中所规定。
PerformanceResourceTiming.nextHopProtocol只读
返回string ,表示用于获取资源的网络协议,由ALPN Protocol ID (RFC7301)标识。
PerformanceResourceTiming.workerStart只读
如果Service Worker线程已在运行,则在调用FetchEvent之前立即返回DOMHighResTimeStamp,如果尚未运行,则在启动Service Worker线程之前立即返回DOMHighResTimeStamp。 如果资源未被Service Worker拦截,则该属性将始终返回0。
PerformanceResourceTiming.redirectStart只读
返回DOMHighResTimeStamp, 表示初始重定向的开始获取时间。
PerformanceResourceTiming.redirectEnd只读
返回DOMHighResTimeStamp ,紧接在收到最后一次重定向响应的最后一个字节后。
PerformanceResourceTiming.fetchStart只读
返回DOMHighResTimeStamp ,紧接在浏览器开始获取资源之前。
PerformanceResourceTiming.domainLookupStart只读
返回DOMHighResTimeStamp,紧接在浏览器启动资源的域名查找之前。
PerformanceResourceTiming.domainLookupEnd只读
返回DOMHighResTimeStamp ,表示浏览器完成资源的域名查找后的时间。
PerformanceResourceTiming.connectStart只读
返回DOMHighResTimeStamp ,紧接在浏览器检索资源,开始建立与服务器的连接之前。
PerformanceResourceTiming.connectEnd只读
返回DOMHighResTimeStamp ,紧接在浏览器完成与服务器的连接以检索资源之后。
PerformanceResourceTiming.secureConnectionStart只读
返回DOMHighResTimeStamp ,紧接在浏览器启动握手过程之前,以保护当前连接。
PerformanceResourceTiming.requestStart只读
返回DOMHighResTimeStamp ,紧接在浏览器开始从服务器请求资源之前。
PerformanceResourceTiming.responseStart只读
返回DOMHighResTimeStamp ,紧接在浏览器收到服务器响应的第一个字节后。
PerformanceResourceTiming.responseEnd只读
返回DOMHighResTimeStamp ,紧接在浏览器收到资源的最后一个字节之后或紧接在传输连接关闭之前,以先到者为准。
PerformanceResourceTiming.transferSize只读
表示获取资源的大小(以八位字节为单位)的数字。 包括响应头字段和响应payload body的大小。
PerformanceResourceTiming.encodedBodySize只读
在删除任何应用的内容编码之前,从payload body的提取(HTTP或高速缓存)接收的大小(以八位字节为单位)的数字
PerformanceResourceTiming.decodedBodySize只读
在删除任何应用的内容编码之后,从消息正文( message body )的提取(HTTP或缓存)接收的大小(以八位字节为单位)的数字
PerformanceResourceTiming.serverTiming只读
包含服务器时序度量( timing metrics )的PerformanceServerTiming 条目数组。

方法

PerformanceResourceTiming.toJSON()
返回DOMString, 它是 PerformanceResourceTiming 对象的JSON表示形式。

Example

See the example in Using the Resource Timing API.

规范

Specification Status Comment
Resource Timing Level 1
PerformanceResourceTiming
Candidate Recommendation Initial definition.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
PerformanceResourceTimingChrome Full support 43Edge Full support YesFirefox Full support 40IE Full support 10Opera Full support 30Safari Full support 11WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 42Opera Android Full support 30Safari iOS Full support 11Samsung Internet Android Full support 4.0
connectEndChrome Full support 43Edge Full support 12Firefox Full support 40IE Full support 10Opera Full support 32Safari Full support 11WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 42Opera Android Full support 32Safari iOS Full support 11Samsung Internet Android Full support 4.0
connectStartChrome Full support 43Edge Full support 12Firefox Full support 40IE Full support 10Opera Full support 32Safari Full support 11WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 42Opera Android Full support 32Safari iOS Full support 11Samsung Internet Android Full support 4.0
decodedBodySizeChrome Full support 54Edge Full support 17Firefox Full support 45IE No support NoOpera Full support 41Safari No support NoWebView Android Full support 54Chrome Android Full support 54Firefox Android Full support 45Opera Android Full support 41Safari iOS No support NoSamsung Internet Android Full support 6.0
domainLookupEndChrome Full support 43Edge Full support 12Firefox Full support 40IE No support NoOpera Full support 30Safari Full support 11WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 42Opera Android Full support 30Safari iOS Full support 11Samsung Internet Android Full support 4.0
domainLookupStartChrome Full support 43Edge Full support 12Firefox Full support 40IE No support NoOpera Full support 30Safari Full support 11WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 42Opera Android Full support 30Safari iOS Full support 11Samsung Internet Android Full support 4.0
encodedBodySizeChrome Full support 54Edge Full support 17Firefox Full support 45IE No support NoOpera Full support 41Safari No support NoWebView Android Full support 54Chrome Android Full support 54Firefox Android Full support 45Opera Android Full support 41Safari iOS No support NoSamsung Internet Android Full support 6.0
fetchStartChrome Full support 43Edge Full support 12Firefox Full support 40IE No support NoOpera Full support 30Safari Full support 11WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 42Opera Android Full support 30Safari iOS Full support 11Samsung Internet Android Full support 4.0
initiatorTypeChrome Full support 43Edge Full support 12Firefox Full support 40IE No support NoOpera Full support 30Safari Full support 11WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 42Opera Android Full support 30Safari iOS Full support 11Samsung Internet Android Full support 4.0
nextHopProtocolChrome Full support 61Edge Full support 17Firefox Full support 45IE No support NoOpera No support NoSafari No support NoWebView Android Full support 61Chrome Android Full support 61Firefox Android Full support 45Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support No
redirectEndChrome Full support 43Edge Full support 12Firefox Full support 40IE No support NoOpera Full support 30Safari Full support 11WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 42Opera Android Full support 30Safari iOS Full support 11Samsung Internet Android Full support 4.0
redirectStartChrome Full support 43Edge Full support 12Firefox Full support 40IE No support NoOpera Full support 30Safari Full support 11WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 42Opera Android Full support 30Safari iOS Full support 11Samsung Internet Android Full support 4.0
requestStartChrome Full support 43Edge Full support 12Firefox Full support 40IE No support NoOpera Full support 30Safari Full support 11WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 42Opera Android Full support 30Safari iOS Full support 11Samsung Internet Android Full support 4.0
responseEndChrome Full support 43Edge Full support 12Firefox Full support 40IE No support NoOpera Full support 30Safari Full support 11WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 42Opera Android Full support 30Safari iOS Full support 11Samsung Internet Android Full support 4.0
responseStartChrome Full support 43Edge Full support 12Firefox Full support 40IE No support NoOpera Full support 30Safari Full support 11WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 42Opera Android Full support 30Safari iOS Full support 11Samsung Internet Android Full support 4.0
secureConnectionStartChrome Full support 43Edge Full support 18Firefox Full support 40IE No support NoOpera Full support 30Safari Full support 11WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 42Opera Android Full support 30Safari iOS Full support 11Samsung Internet Android Full support 4.0
serverTimingChrome Full support 65Edge ? Firefox Full support 61IE No support NoOpera Full support 52Safari ? WebView Android Full support 65Chrome Android Full support 65Firefox Android Full support 61Opera Android Full support 47Safari iOS ? Samsung Internet Android Full support Yes
toJSONChrome Full support 43Edge Full support YesFirefox Full support 40IE No support NoOpera Full support 30Safari Full support 11WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 42Opera Android Full support 30Safari iOS Full support 11Samsung Internet Android Full support 4.0
transferSizeChrome Full support 54Edge Full support 17Firefox Full support 45IE No support NoOpera Full support 41Safari No support NoWebView Android Full support 54Chrome Android Full support 54Firefox Android Full support 45Opera Android Full support 41Safari iOS No support NoSamsung Internet Android Full support 6.0
Available in workersChrome Full support 43Edge Full support YesFirefox Full support 60IE No support NoOpera Full support 32Safari No support NoWebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 60Opera Android Full support 32Safari iOS No support NoSamsung Internet Android Full support 4.0
workerStartChrome Full support 43Edge Full support 16Firefox Full support 58IE No support NoOpera Full support 32Safari Full support 11WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 58Opera Android Full support 32Safari iOS Full support 11Samsung Internet Android Full support 4.0

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

参考

文档标签和贡献者

此页面的贡献者: zhanym
最后编辑者: zhanym,