Collecting client side Performance Metrics from Ph

2019-03-03 23:54发布

问题:

Throughout PhantonJS Driver Config is there any way we can capture the following client-side performance metrics through phantomjs by using Jmeter DomLoad windLoad ResourceCount Resource size.

Thanks

回答1:

I would recommend capturing the metrics using WDS.browser.executeScript() method which allows executing arbitrary JavaScript code. Once done you can directly store "interesting" values into JMeter Variables for later use.

Here is an example of using Navigation API to get extended information on page loading:

WDS.sampleResult.sampleStart()
WDS.browser.get('http://jmeter-plugins.org')
var timings = WDS.browser.executeScript('var performance = window.performance || window.webkitPerformance || window.mozPerformance || window.msPerformance || {}; var timings = performance.timing || {}; return timings;');
WDS.log.info(timings)
WDS.sampleResult.sampleEnd()

See The WebDriver Sampler: Your Top 10 Questions Answered guide for WebDriver Sampler tips and tricks