jdiver
jdiver

Reputation: 2348

HTMLUnit Page Load Time Calculation

I connect and load a page with HTMLUnit simply with the following code.

final WebClient webClient = new WebClient(BrowserVersion.CHROME);
final HtmlPage page = webClient.getPage("http://htmlunit.sourceforge.net");

When getPage method completed, HTMLUnit is also finished parsing page (html, javascript etc).

How can I calculate just page download time? I need an indication or event that page download is completed and HTMLUnit is started parsing downloaded page content.

Upvotes: 0

Views: 829

Answers (1)

jdiver
jdiver

Reputation: 2348

Finally found the solution, after fully loading and parsing HtmlPage, it has a method to get WebResponse. WebResponse gives load time with method getLoadTime()

Returns the time it took to load this web response, in milliseconds.

page.getWebResponse().getLoadTime();

Upvotes: 2

Related Questions