I am planning to develop code for measure Web page loading time using HtmlUnit
Below is my code
public static void main(String[] args) throws IOException {
final WebClient webClient = new WebClient(BrowserVersion.CHROME);
webClient.getOptions().setUseInsecureSSL(true);
final HtmlPage page = webClient.getPage("http://www.gmail.com/");
long time = page.getWebResponse().getLoadTime();
long loadEventEnd = Long.parseLong(page.executeJavaScript("window.performance.timing.loadEventEnd").getJavaScriptResult().toString());
long navigationStart = Long.parseLong(page.executeJavaScript("window.performance.timing.navigationStart").getJavaScriptResult().toString());
long timejs = loadEventEnd-navigationStart;
System.out.println("Html Unit Time : " + time + " JS Time : "+timejs);
}
when i execute the code each every time i got same result in the "timejs"
(i am comparing both times as a test)
i am stuck in here, please help me
The timing API is more or less a mock at the moment (version 2.32). Have a look at the code.
As always patches are welcome.