gpt4 book ai didi

java - 如何从性能日志计算页面加载时间、domContentLoaded 时间(即公式)?

转载 作者:行者123 更新时间:2023-12-01 23:36:07 25 4
gpt4 key购买 nike

我正在使用 Selenium API 和 chromeDriver 来获取性能日志 - 成功!例如下面的一部分。

{ 
"name":"http://ginsoy.com/",
"entryType":"navigation",
"startTime":0,
"duration":16242.659999988973,
"initiatorType":"navigation",
"nextHopProtocol":"http/1.1",
"workerStart":0,
"redirectStart":0,
"redirectEnd":0,
"fetchStart":2386.3250000867993,
"domainLookupStart":2388.289999915287,
"domainLookupEnd":2388.895000098273,
"connectStart":2388.895000098273,
"connectEnd":2654.6849999576807,
"secureConnectionStart":0,
"requestStart":2654.80999997817,
"responseStart":4028.944999910891,
"responseEnd":4340.390000026673,
"transferSize":18214,
"encodedBodySize":17458,
"decodedBodySize":79194,
"serverTiming":[

],
"unloadEventStart":0,
"unloadEventEnd":0,
"domInteractive":11488.489999901503,
"domContentLoadedEventStart":11488.804999971762,
"domContentLoadedEventEnd":11597.39000000991,
"domComplete":16240.054999943823,
"loadEventStart":16240.114999935031,
"loadEventEnd":16242.659999988973,
"type":"navigate",
"redirectCount":0
},
{
"name":"http://ginsoy.com/wpcontent/plugins/wmzoom/css/style.css?ver=4.4.2",
"entryType":"resource",
"startTime":4054.6500000637025,
"duration":337.7549999859184,
"initiatorType":"link",
"nextHopProtocol":"http/1.1",
"workerStart":0,
"redirectStart":0,
"redirectEnd":0,
"fetchStart":4054.6500000637025,
"domainLookupStart":4054.6500000637025,
"domainLookupEnd":4054.6500000637025,
"connectStart":4054.6500000637025,
"connectEnd":4054.6500000637025,
"secureConnectionStart":0,
"requestStart":4060.2800000924617,
"responseStart":4362.519999966025,
"responseEnd":4392.405000049621,
"transferSize":526,
"encodedBodySize":168,
"decodedBodySize":206,
"serverTiming":[

]
}
}

我正在使用 Java 创建一个应用程序,需要计算页面的加载时间、请求数、DomContentloaded 时间和一些其他因素。

问题是:

要添加哪些元素来获取加载时间 domContentLoad,或者在哪里可以找到公式指南?

- PageLoadTime = 12.4ms
- DomContentLoaded = 9ms

最佳答案

根据 DOMContentLoaded event description

The DOMContentLoaded event fires when the initial HTML document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading.

如果这确实是您要寻找的内容,您可以通过减去 navigationStart 来得到它来自domContentLoadedEventEnd像:

Object domContentLoaded = driver.executeScript("return(parseInt(window.performance.timing.domContentLoadedEventEnd)-parseInt(window.performance.timing.navigationStart));")

这是 JMeter's WebDriver Sampler 的样子:

enter image description here

关于java - 如何从性能日志计算页面加载时间、domContentLoaded 时间(即公式)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58276599/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com