本文介绍了Chrome:性能数据的 API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题描述

在使用 Selenium 时,如何从浏览器控制台或使用 Chrome 驱动程序方法访问 Chrome 性能工具中的数据?

特别是,我对获取页面加载时间很感兴趣.在顶部图表中,我可以看到最后一个元素在 1700-1800 毫秒 标记附近加载.底部的事件日志显示最后一个元素在页面重新加载后 1720.1 毫秒开始加载(并在几毫秒内完成).

到目前为止我尝试了什么

我尝试使用 Performance Timing interface 像这样:

console.log(performance.timing.loadEventEnd -performance.timing.navigationStart)357

但我想它可以衡量其他一些性能.loadEventEndnavigationStarttiming 的属性中是最极端的,它们的差值只有 357(ms).

我也尝试过像这样使用 Selenium 记录性能信息(从 此处 和用 Python 重写):

导入时间导入json导入副本从硒导入网络驱动程序从 selenium.webdriver.common.desired_capabilities 导入 DesiredCapabilities从 selenium.webdriver.chrome.options 导入选项caps = copy.deepcopy(DesiredCapabilities.CHROME)caps['loggingPrefs'] = {'performance': 'ALL'}chromedriver_options = 选项()chromedriver_options.add_argument("--headless")chromedriver_options.add_argument("--window-size=1920,1080")chromedriver_options.add_argument("--log-level=3") # 禁止 selenium 日志记录到标准输出驱动程序 = webdriver.Chrome(chrome_options=chromedriver_options,executable_path='chromedriver.exe',desired_capabilities=caps)driver.set_window_position(0, 0)driver.implicitly_wait(8) # 设置超时时间为 8 秒driver.get(my_url)time.sleep(5) # 等待页面第一次加载_ = driver.get_log('performance') # 丢弃所有以前的日志驱动程序刷新()time.sleep(5) # 在写日志之前确保页面完全加载with open('logs.txt', 'a') as f:在 driver.get_log('performance') 中输入:f.write(str(entry) + '
')驱动程序关闭()

结果日志包含调用 Page.frameStartedLoadingPage.frameStoppedLoading 方法及其时间戳的条目,我想测量第一个 Page.frameStartedLoading 和刷新日志并调用 driver.refresh() 后的最后一个 Page.frameStoppedLoading.

不幸的是,生成的日志文件没有多大意义.性能日志不会停止(我认为它应该停止,因为网页在某个时候被加载并且在性能方面没有发生任何事情).如果我在刷新后调用 time.sleep(5),我会得到一些日志,其中包含对每个 Page.frameStartedLoadingPage.frameStoppedLoading 的 5 次调用.如果我调用 time.sleep(7),我会得到 7 个对每个 Page.frameStartedLoadingPage.frameStoppedLoading 的调用.最后一个 Page.frameStoppedLoading 的时间戳和第一个 Page.frameStartedLoading 的时间戳之间的差异在最后一种情况下约为 7 秒,这显然不是我想要的.>

任何人都有捕获此页面加载性能信息的经验?

解决方案

如果您想使用 ChromeDriverChrome 开发者工具 访问性能数据/strong>您可以使用以下代码块:

  • Selenium-Python 代码段

    from selenium import webdriverdriver=webdriver.Chrome(executable_path=r'C:UtilityBrowserDriverschromedriver.exe')driver.get("http://www.google.com")performance_data = driver.execute_script("返回 window.performance.getEntries();")打印(性能数据)

  • 提取的参数如下:

    connectEnd 服务器连接完成的时间.connectStart 服务器连接开始前的时间.domComplete 文档准备完成之前的时间.domContentLoadedEventEnd DOMContentLoaded 事件完成后的时间.domContentLoadedEventStart 刚好在 DOMContentLoaded 开始之前的时间.domInteractive 准备设置为交互式之前的时间.domLoading 准备设置为加载之前的时间.domainLookupEnd 域名查找后的时间.domainLookupStart 域名查找前的时间.fetchStart 开始获取资源的时间.loadEventEnd 加载事件完成的时间.loadEventStart 触发加载事件之前的时间.navigationStart 前一个文档开始卸载后的时间.redirectCount 自上次非重定向以来的重定向次数.redirectEnd 上次重定向响应结束后的时间.redirectStart 启动重定向的提取时间.requestStart 就在服务器请求之前的时间.responseEnd 响应或连接结束后的时间.responseStart 响应开始前的时间.对性能计时对象的引用.导航参考性能导航对象.性能参考窗口的性能对象.type 最后一个非重定向导航事件的类型.unloadEventEnd 上一个文档卸载后的时间.unloadEventStart 触发卸载事件之前的时间.

控制台输出:

页面标题是:谷歌[{ 'connectEnd':2725.146514015987, 'connectStart':1503.1734234800108, 'decodedBodySize':204837, 'domComplete':7603.4821342458235, 'domContentLoadedEventEnd':4588.4400826362535, 'domContentLoadedEventStart':4576.987229310746, 'domInteractive':4559.208601432438, 'domainLookupEnd':1503.1734234800108,'domainLookupStart':1503.1734234800108, '时间':7623.300733238722, 'encodedBodySize':61075, 'entryType': '导航', 'fetchStart':1503.1734234800108, 'initiatorType': '导航', 'loadEventEnd':7623.300733238722, 'loadEventStart':7603.516579526861, '名称': '文件', 'nextHopProtocol': 'H2', 'redirectCount':0, 'redirectEnd':1501.686197816412, 'redirectStart':22.057947498907886, 'requestStart':2725.729247123413, 'responseEnd':3624.7713441197043,responseStart': 3349.3679493549, 'secureConnectionStart': 2049.7916668355165, 'startTime': 0, 'transferSize': 61926, 'type': 'navigate', 'unloadEventEnd': 0, '},'unload,Event: 0连接结束":3388.3040845619494, 'connectStart':3388.3040845619494, 'decodedBodySize':1730年, 'domainLookupEnd':3388.3040845619494, 'domainLookupStart':3388.3040845619494, '持续时间':237.3373068328902, 'encodedBodySize':1730年, 'entryType': '资源', 'fetchStart':3388.3040845619494,'initiatorType':'img','name':'https://www.google.co.in/logos/doodles/2018/doodle-snow-games-day-15-5907794870927360.4-s.png''nextHopProtocol': 'H2', 'redirectEnd':0, 'redirectStart':0, 'requestStart':3439.3892730100556, 'responseEnd':3625.6413913948395, 'responseStart':3625.271003314041, 'secureConnectionStart':0, '开始时间':3388.3040845619494,'transferSize':2242,'workerStart':0},{'connectEnd':0,'connectStart':0,'decodedBodySize':0,'domainLookupEnd':0,'domainLookupStart':0,'duration':230.207944613542'encodedBodySize':0,'entryType':'resource','fetchStart':3425.689371645131,'initiatorType':'css','name':'https://ssl.gstatic.com/gb/images/i1_1967ca6a6a', 'nextHopProtocol': 'h2', 'redirectEnd':0,'redirectStart':0,'requestStart':0,'responseEnd':3655.8973157805594,'responseStart':0,'secureConnectionStart':0,'startTime':3425.689371645131'transferStart'::0},{'connectEnd':0,'connectStart':0,'decodedBodySize':0,'domainLookupEnd':0,'domainLookupStart':0,'duration':969.9734406621285,'encodedBodySize':0,'entryType': 'resource', 'fetchStart': 3502.3913129811713, 'initiatorType': 'script', 'name': 'https://www.gstatic.com/external_hosted/createjs/createjs-2015.11.26.min.js', 'nextHopProtocol':'h2','redirectEnd':0,'redirectStart':0,'requestStart':0,'responseEnd':4472.364753643298,'responseStart':0,'secureConnectionStart':0,'startTime',931212transferSize ':0, 'workerStart':0},{' connectEnd ':3520.930168473896, 'connectStart':3520.930168473896, 'decodedBodySize':12232, 'domainLookupEnd':3520.930168473896, 'domainLookupStart':3520.930168473896, '时间':134.0411771046674,'编码的身体大小':12232,'entryType':'resource','fetchStart':3520.930168473896,'initiatorType':'css','name':'https://www.google.co.in/logos/2018/snowgames_bosled/cta.png','nextHopProtocol': 'h2', 'redirectEnd': 0, 'redirectStart': 0, 'requestStart': 3525.3821197382813, 'responseEnd': 3654.971345578564, 'responseStart': 3565373TimeStart', 35653753:3565375375373'transferSize':12745, 'workerStart':0},{ 'connectEnd':4527.024551785848, 'connectStart':4527.024551785848, 'decodedBodySize':842405, 'domainLookupEnd':4527.024551785848, 'domainLookupStart':4527.024551785848, '时间':2632.3253968704244,'encodedBodySize':265174,'entryType':'resource','fetchStart':4527.024551785848,'initiatorType':'script','name':'https://www.google.co.in/logos/2018/bobsledgames_/snowgames_bosled18.2.js', 'nextHopProtocol': 'h2', 'redirectEnd': 0, 'redirectStart': 0, 'requestStart': 4528.843667863202, 'responseEnd': 7159.3499463656565659765656868、'secureConnectionStart': 0, 'startTime': 4527.024551785848, 'transferSize': 265741, 'workerStart': 0}, {'connectEnd': 4558.896162471504, 'connectStart', 840dB05LookSize:45600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004558.896162471504, 'domainLookupStart': 4558.896162471504, 'duration': 1005.3106518587082, 'encodedBodySize': 0, 'entryType':'155084', '155084'https: '155084', '155084'https:/www.google.co.in/gen_204?s=webaft&atyp=csi&ei=N6mPWp6mC8H00ASJtoL4Ag&rt=wsrt.3384,aft.1175,prt.1175', 'nextHop2End':'rehop2End0, 'redirectStart': 0, 'requestStart': 4560.575876470308, 'responseEnd': 5564.206814330209, 'responseStart': 5564.1444075857435, 'secureConnectionStart'85353504', 'secureConnectionStart', 845350450450450450450450450504505000, {'connectEnd': 4576.353841378264, 'connectStart': 4576.353841378264, 'decodedBodySize': 417606, 'domainLookupEnd': 4576.3538413782658264, 'domainLookupEnd': 4576.353841378264, 'domainLookupEnd'.3737464,903.6302084304214, 'encodedBodySize': 144417, 'entryType': 'resource', 'fetchStart': 4576.353841378264, 'initiatorType': 'script', 'name': ./_inx/www.google.cn/js/k=xjs.s.en.smQ6-n1iGHA.O/m=sx,sb,cdos,cr,elog,hsm,jsa,r,d,csi/am=wCLkeMEAyP8JgogEKwgsQIpgGBA/rt=j/d=1/吨= ZCMS/RS = ACT90oH8FZej9QmzW2qBqlOOQ7DASmnKAA ' 'nextHopProtocol': 'H2', 'redirectEnd':0, 'redirectStart':0, 'requestStart':4578.110550711152, 'responseEnd':6479.984049808687, 'responseStart':5564.372556917789,' secureConnectionStart':0,'startTime':4576.353841378264,'transferSize':144999,'workerStart':0},{'connectEnd':0,'connectStart':0,'decodedBodySize':0,'domainLookupEnd':0': 0, 'duration': 574.9679253647753, 'encodedBodySize': 0, 'entryType': 'resource', 'fetchStart': 4791.30009458269, 'initiatorType': 'script', 'https://name..com/og/_/js/k=og.og2.en_US.SpCLDXmWlPM.O/rt=j/m=def/exm=in,fot/d=1/ed=1/rs=AA2YrTtMoJJMGQfOfYZyZ7reaiaiva99OQ', 'nextHopProtocol':'h2','redirectEnd':0,'redirectStart':0,'requestStart':0,'responseEnd':5366.2680199474635,'responseStart':0,'secureConnectionStart':0,'startTime':4791.30009,'transferSize66workerStart':0},{'connectEnd':0,'connectStart':0,'decodedBodySize':0,'domainLookupEnd':0,'domainLookupStart':0,'duration':1586.0147296126488,'encodedBodySize':0entryType':'resource','fetchStart':5417.5655534222005,'initiatorType':'script','name':'https://apis.google.com/_/scs/abc-static/_/js/k=gapi.gapi.en.29tAKSAI8cc.O/m=gapi_iframes,googleapis_client,plusone/rt=j/sv=1/d=1/ed=1/am=IA/rs=AHpOoo82FxkTgGRAoVn-fgFU3zdQ5QIqEw/cb='gapi., 'nextHopProtocol': 'h2', 'redirectEnd': 0, 'redirectStart': 0, 'requestStart': 0, 'responseEnd': 7003.580283034848, 'responseStart': 0, 'secureConnectionStart': 0, '45205205​​3':,'transferSize':0,'workerStart':0},{'connectEnd':6646.626267079796,'connectStart':6646.626267079796,'decodedBodySize':83168,'域LookupEnd ':6646.626267079796, 'domainLookupStart':6646.626267079796, '持续时间':783.8056119062338, 'encodedBodySize':27299, 'entryType': '资源', 'fetchStart':6646.626267079796, 'initiatorType': '剧本', '名':'https://www.google.co.in/xjs/_/js/k=xjs.s.en.smQ6-n1iGHA.O/m=aa,abd,async,dvl,foot,fpe,ipv6,lu,m,mu,sf,sonic,d3l/am=wCLkeMEAyP8JgogEKwgsQIpgGBA/exm=sx,sb,cdos,cr,elog,hsm,jsa,r,d,csi/rt=j/d=1/ed=1/t=ZCMS/RS = ACT90oH8FZej9QmzW2qBqlOOQ7DASmnKAA XJS = S1' , 'nextHopProtocol?': 'H2', 'redirectEnd':0, 'redirectStart':0, 'requestStart':6648.111871788991, 'responseEnd':7430.431878986027, 'responseStart':7159.731278179281,'secureConnectionStart':0,'startTime':6646.626267079796,'transferSize':27880,'workerStart':0},{'connectEnd':0,'connectStart':0,'decodedBodySize':0,'domainLookupEnd':0}domainLookupStart': 0, 'duration': 930.0310980101976, 'encodedBodySize': 0, 'entryType': 'resource', 'fetchStart': 6668.677730761095, 'initiatorType': 'name 'https'www.google.com/textinputassistant/tia.png','nextHopProtocol':'h2','redirectEnd':0,'redirectStart':0,'requestStart':0,'responseEnd':7598.708828771292,'responseStart':0, 'secureConnectionStart': 0, 'startTime': 6668.677730761095, 'transferSize': 0, 'workerStart': 0}, {'connectEnd': 7222.302954756732, 'connectStart': 72252,7567300000000000000000000000000,000,000,000,000,000,000,000,000,000,000,000,000,000', 'domainLookupStart': 7222.302954756732, 'duration': 208.68612730489625, 'encodedBodySize': 469, 'entryType': 'resource', 'fetchStartType': 722532,752'img:72252,752'inwww.google.co.in/logos/2018/snowgames_bosled/main-sprite.png','nextHopProtocol':'h2','redirectEnd':0,'redirectStart':0,'requestStart':7223.911346761861,'responseEnd': 7430.989082061627, 'responseStart': 7430.7698479787905, 'secureConnectionStart': 0, 'startTime': 7222.302954756732, 'transferSize': 980, 'worker]]

从此输出中,您可以轻松提取您感兴趣的性能统计.

Problem Descritpion

How can I access the data from the Chrome Performance tool either from the browser console or using Chrome driver methods when using Selenium?

In particular, I am interested in getting the page loading time. On the top diagrams I can see that the last elements were loaded around 1700-1800 ms mark. The event log in the bottom shows that the last element started loading (and finished in a few ms) at 1720.1 ms from the time the page was reloaded.

What I Tried So Far

I tried using Performance Timing interface like this:

console.log(performance.timing.loadEventEnd -
performance.timing.navigationStart)
357

But I guess it measures some other performance. loadEventEnd and navigationStart have the most extreme values among the attributes of timing and their difference is only 357 (ms).

I also tried logging performance info using Selenium like this (took some ideas from here and rewrote in Python):

import time
import json
import copy
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.chrome.options import Options

caps = copy.deepcopy(DesiredCapabilities.CHROME)
caps['loggingPrefs'] = {'performance': 'ALL'}
chromedriver_options = Options()
chromedriver_options.add_argument("--headless")
chromedriver_options.add_argument("--window-size=1920,1080")
chromedriver_options.add_argument("--log-level=3") # suppress selenium logging to stdout
driver = webdriver.Chrome(chrome_options=chromedriver_options, executable_path='chromedriver.exe', desired_capabilities=caps)
driver.set_window_position(0, 0)
driver.implicitly_wait(8) # set timeout to 8 seconds
driver.get(my_url)
time.sleep(5) # wait for page to load for the first time
_ = driver.get_log('performance') # discard all previous logs
driver.refresh()
time.sleep(5) # make sure page loaded completely before writing log
with open('logs.txt', 'a') as f:
    for entry in driver.get_log('performance'):
        f.write(str(entry) + '
')
driver.close()

The resulting logs contain entries with calls to Page.frameStartedLoading and Page.frameStoppedLoading methods and their timestamps and I had an idea to measure the time between the first Page.frameStartedLoading and the last Page.frameStoppedLoading after flushing the log and calling driver.refresh().

Unfortunately, the resulting log file doesn't make a lot of sense. The performance logging doesn't stop (I thought it should since the web page is loaded at some point and nothing is happening performance-wise). If I call time.sleep(5) after refreshing, I would get some logs with 5 calls to each Page.frameStartedLoading and Page.frameStoppedLoading. If I call time.sleep(7) I would get 7 calls to each Page.frameStartedLoading and Page.frameStoppedLoading. And the difference between timestamp of the last Page.frameStoppedLoading and the first Page.frameStartedLoading would be ~7 seconds in this last case which is clearly not what I wanted.

Anyone has experience with capturing this page loading performance info?

解决方案

If you want to access the Performance Data from the Chrome Developer Tool using ChromeDriver you can use the following code block :

  • Selenium-Python Snippet

    from selenium import webdriver
    
    driver=webdriver.Chrome(executable_path=r'C:UtilityBrowserDriverschromedriver.exe')
    driver.get("http://www.google.com")
    performance_data = driver.execute_script("return window.performance.getEntries();")
    print (performance_data)
    

  • The parameters extracted are as follows :

    connectEnd                 Time when server connection is finished.
    connectStart               Time just before server connection begins.
    domComplete                Time just before document readiness completes.
    domContentLoadedEventEnd   Time after DOMContentLoaded event completes.
    domContentLoadedEventStart Time just before DOMContentLoaded starts.
    domInteractive             Time just before readiness set to interactive.
    domLoading                 Time just before readiness set to loading.
    domainLookupEnd            Time after domain name lookup.
    domainLookupStart          Time just before domain name lookup.
    fetchStart                 Time when the resource starts being fetched.
    loadEventEnd               Time when the load event is complete.
    loadEventStart             Time just before the load event is fired.
    navigationStart            Time after the previous document begins unload.
    redirectCount              Number of redirects since the last non-redirect.
    redirectEnd                Time after last redirect response ends.
    redirectStart              Time of fetch that initiated a redirect.
    requestStart               Time just before a server request.
    responseEnd                Time after the end of a response or connection.
    responseStart              Time just before the start of a response.
    timing                     Reference to a performance timing object.
    navigation                 Reference to performance navigation object.
    performance                Reference to performance object for a window.
    type                       Type of the last non-redirect navigation event.
    unloadEventEnd             Time after the previous document is unloaded.
    unloadEventStart           Time just before the unload event is fired.
    

Console Output :

Page Title is : Google
[{'connectEnd': 2725.146514015987, 'connectStart': 1503.1734234800108, 'decodedBodySize': 204837, 'domComplete': 7603.4821342458235, 'domContentLoadedEventEnd': 4588.4400826362535, 'domContentLoadedEventStart': 4576.987229310746, 'domInteractive': 4559.208601432438, 'domainLookupEnd': 1503.1734234800108, 'domainLookupStart': 1503.1734234800108, 'duration': 7623.300733238722, 'encodedBodySize': 61075, 'entryType': 'navigation', 'fetchStart': 1503.1734234800108, 'initiatorType': 'navigation', 'loadEventEnd': 7623.300733238722, 'loadEventStart': 7603.516579526861, 'name': 'document', 'nextHopProtocol': 'h2', 'redirectCount': 0, 'redirectEnd': 1501.686197816412, 'redirectStart': 22.057947498907886, 'requestStart': 2725.729247123413, 'responseEnd': 3624.7713441197043, 'responseStart': 3349.3679493549, 'secureConnectionStart': 2049.7916668355165, 'startTime': 0, 'transferSize': 61926, 'type': 'navigate', 'unloadEventEnd': 0, 'unloadEventStart': 0, 'workerStart': 0}, {'connectEnd': 3388.3040845619494, 'connectStart': 3388.3040845619494, 'decodedBodySize': 1730, 'domainLookupEnd': 3388.3040845619494, 'domainLookupStart': 3388.3040845619494, 'duration': 237.3373068328902, 'encodedBodySize': 1730, 'entryType': 'resource', 'fetchStart': 3388.3040845619494, 'initiatorType': 'img', 'name': 'https://www.google.co.in/logos/doodles/2018/doodle-snow-games-day-15-5907794870927360.4-s.png', 'nextHopProtocol': 'h2', 'redirectEnd': 0, 'redirectStart': 0, 'requestStart': 3439.3892730100556, 'responseEnd': 3625.6413913948395, 'responseStart': 3625.271003314041, 'secureConnectionStart': 0, 'startTime': 3388.3040845619494, 'transferSize': 2242, 'workerStart': 0}, {'connectEnd': 0, 'connectStart': 0, 'decodedBodySize': 0, 'domainLookupEnd': 0, 'domainLookupStart': 0, 'duration': 230.20794413542762, 'encodedBodySize': 0, 'entryType': 'resource', 'fetchStart': 3425.689371645131, 'initiatorType': 'css', 'name': 'https://ssl.gstatic.com/gb/images/i1_1967ca6a.png', 'nextHopProtocol': 'h2', 'redirectEnd': 0, 'redirectStart': 0, 'requestStart': 0, 'responseEnd': 3655.8973157805594, 'responseStart': 0, 'secureConnectionStart': 0, 'startTime': 3425.689371645131, 'transferSize': 0, 'workerStart': 0}, {'connectEnd': 0, 'connectStart': 0, 'decodedBodySize': 0, 'domainLookupEnd': 0, 'domainLookupStart': 0, 'duration': 969.9734406621285, 'encodedBodySize': 0, 'entryType': 'resource', 'fetchStart': 3502.3913129811713, 'initiatorType': 'script', 'name': 'https://www.gstatic.com/external_hosted/createjs/createjs-2015.11.26.min.js', 'nextHopProtocol': 'h2', 'redirectEnd': 0, 'redirectStart': 0, 'requestStart': 0, 'responseEnd': 4472.364753643298, 'responseStart': 0, 'secureConnectionStart': 0, 'startTime': 3502.3913129811713, 'transferSize': 0, 'workerStart': 0}, {'connectEnd': 3520.930168473896, 'connectStart': 3520.930168473896, 'decodedBodySize': 12232, 'domainLookupEnd': 3520.930168473896, 'domainLookupStart': 3520.930168473896, 'duration': 134.0411771046674, 'encodedBodySize': 12232, 'entryType': 'resource', 'fetchStart': 3520.930168473896, 'initiatorType': 'css', 'name': 'https://www.google.co.in/logos/2018/snowgames_bobsled/cta.png', 'nextHopProtocol': 'h2', 'redirectEnd': 0, 'redirectStart': 0, 'requestStart': 3525.3821197382813, 'responseEnd': 3654.971345578564, 'responseStart': 3625.955856548778, 'secureConnectionStart': 0, 'startTime': 3520.930168473896, 'transferSize': 12745, 'workerStart': 0}, {'connectEnd': 4527.024551785848, 'connectStart': 4527.024551785848, 'decodedBodySize': 842405, 'domainLookupEnd': 4527.024551785848, 'domainLookupStart': 4527.024551785848, 'duration': 2632.3253968704244, 'encodedBodySize': 265174, 'entryType': 'resource', 'fetchStart': 4527.024551785848, 'initiatorType': 'script', 'name': 'https://www.google.co.in/logos/2018/snowgames_bobsled/snowgames_bobsled18.2.js', 'nextHopProtocol': 'h2', 'redirectEnd': 0, 'redirectStart': 0, 'requestStart': 4528.843667863202, 'responseEnd': 7159.3499486562705, 'responseStart': 4946.163646693538, 'secureConnectionStart': 0, 'startTime': 4527.024551785848, 'transferSize': 265741, 'workerStart': 0}, {'connectEnd': 4558.896162471504, 'connectStart': 4558.896162471504, 'decodedBodySize': 0, 'domainLookupEnd': 4558.896162471504, 'domainLookupStart': 4558.896162471504, 'duration': 1005.3106518587082, 'encodedBodySize': 0, 'entryType': 'resource', 'fetchStart': 4558.896162471504, 'initiatorType': 'other', 'name': 'https://www.google.co.in/gen_204?s=webaft&atyp=csi&ei=N6mPWp6mC8H00ASJtoL4Ag&rt=wsrt.3384,aft.1175,prt.1175', 'nextHopProtocol': 'h2', 'redirectEnd': 0, 'redirectStart': 0, 'requestStart': 4560.575876470308, 'responseEnd': 5564.206814330209, 'responseStart': 5564.1444075857435, 'secureConnectionStart': 0, 'startTime': 4558.896162471504, 'transferSize': 358, 'workerStart': 0}, {'connectEnd': 4576.353841378264, 'connectStart': 4576.353841378264, 'decodedBodySize': 417606, 'domainLookupEnd': 4576.353841378264, 'domainLookupStart': 4576.353841378264, 'duration': 1903.6302084304214, 'encodedBodySize': 144417, 'entryType': 'resource', 'fetchStart': 4576.353841378264, 'initiatorType': 'script', 'name': 'https://www.google.co.in/xjs/_/js/k=xjs.s.en.smQ6-n1iGHA.O/m=sx,sb,cdos,cr,elog,hsm,jsa,r,d,csi/am=wCLkeMEAyP8JgogEKwgsQIpgGBA/rt=j/d=1/t=zcms/rs=ACT90oH8FZej9QmzW2qBqlOOQ7DASmnKAA', 'nextHopProtocol': 'h2', 'redirectEnd': 0, 'redirectStart': 0, 'requestStart': 4578.110550711152, 'responseEnd': 6479.984049808687, 'responseStart': 5564.372556917789, 'secureConnectionStart': 0, 'startTime': 4576.353841378264, 'transferSize': 144999, 'workerStart': 0}, {'connectEnd': 0, 'connectStart': 0, 'decodedBodySize': 0, 'domainLookupEnd': 0, 'domainLookupStart': 0, 'duration': 574.9679253647753, 'encodedBodySize': 0, 'entryType': 'resource', 'fetchStart': 4791.30009458269, 'initiatorType': 'script', 'name': 'https://www.gstatic.com/og/_/js/k=og.og2.en_US.SpCLDXmWlPM.O/rt=j/m=def/exm=in,fot/d=1/ed=1/rs=AA2YrTtMoJJMGQfOfYZyZ7reaiaiva99OQ', 'nextHopProtocol': 'h2', 'redirectEnd': 0, 'redirectStart': 0, 'requestStart': 0, 'responseEnd': 5366.2680199474635, 'responseStart': 0, 'secureConnectionStart': 0, 'startTime': 4791.30009458269, 'transferSize': 0, 'workerStart': 0}, {'connectEnd': 0, 'connectStart': 0, 'decodedBodySize': 0, 'domainLookupEnd': 0, 'domainLookupStart': 0, 'duration': 1586.0147296126488, 'encodedBodySize': 0, 'entryType': 'resource', 'fetchStart': 5417.5655534222005, 'initiatorType': 'script', 'name': 'https://apis.google.com/_/scs/abc-static/_/js/k=gapi.gapi.en.29tAKSAI8cc.O/m=gapi_iframes,googleapis_client,plusone/rt=j/sv=1/d=1/ed=1/am=IA/rs=AHpOoo82FxkTgGRAoVn-fgFU3zdQ5QIqEw/cb=gapi.loaded_0', 'nextHopProtocol': 'h2', 'redirectEnd': 0, 'redirectStart': 0, 'requestStart': 0, 'responseEnd': 7003.580283034848, 'responseStart': 0, 'secureConnectionStart': 0, 'startTime': 5417.5655534222005, 'transferSize': 0, 'workerStart': 0}, {'connectEnd': 6646.626267079796, 'connectStart': 6646.626267079796, 'decodedBodySize': 83168, 'domainLookupEnd': 6646.626267079796, 'domainLookupStart': 6646.626267079796, 'duration': 783.8056119062338, 'encodedBodySize': 27299, 'entryType': 'resource', 'fetchStart': 6646.626267079796, 'initiatorType': 'script', 'name': 'https://www.google.co.in/xjs/_/js/k=xjs.s.en.smQ6-n1iGHA.O/m=aa,abd,async,dvl,foot,fpe,ipv6,lu,m,mu,sf,sonic,d3l/am=wCLkeMEAyP8JgogEKwgsQIpgGBA/exm=sx,sb,cdos,cr,elog,hsm,jsa,r,d,csi/rt=j/d=1/ed=1/t=zcms/rs=ACT90oH8FZej9QmzW2qBqlOOQ7DASmnKAA?xjs=s1', 'nextHopProtocol': 'h2', 'redirectEnd': 0, 'redirectStart': 0, 'requestStart': 6648.111871788991, 'responseEnd': 7430.431878986027, 'responseStart': 7159.731278179281, 'secureConnectionStart': 0, 'startTime': 6646.626267079796, 'transferSize': 27880, 'workerStart': 0}, {'connectEnd': 0, 'connectStart': 0, 'decodedBodySize': 0, 'domainLookupEnd': 0, 'domainLookupStart': 0, 'duration': 930.0310980101976, 'encodedBodySize': 0, 'entryType': 'resource', 'fetchStart': 6668.677730761095, 'initiatorType': 'img', 'name': 'https://www.google.com/textinputassistant/tia.png', 'nextHopProtocol': 'h2', 'redirectEnd': 0, 'redirectStart': 0, 'requestStart': 0, 'responseEnd': 7598.708828771292, 'responseStart': 0, 'secureConnectionStart': 0, 'startTime': 6668.677730761095, 'transferSize': 0, 'workerStart': 0}, {'connectEnd': 7222.302954756732, 'connectStart': 7222.302954756732, 'decodedBodySize': 469, 'domainLookupEnd': 7222.302954756732, 'domainLookupStart': 7222.302954756732, 'duration': 208.68612730489625, 'encodedBodySize': 469, 'entryType': 'resource', 'fetchStart': 7222.302954756732, 'initiatorType': 'img', 'name': 'https://www.google.co.in/logos/2018/snowgames_bobsled/main-sprite.png', 'nextHopProtocol': 'h2', 'redirectEnd': 0, 'redirectStart': 0, 'requestStart': 7223.911346761861, 'responseEnd': 7430.989082061627, 'responseStart': 7430.7698479787905, 'secureConnectionStart': 0, 'startTime': 7222.302954756732, 'transferSize': 980, 'workerStart': 0}]

From this output you can easily pull out the performance stats of your interest.

这篇关于Chrome:性能数据的 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 14:50
查看更多