我正计划使用HtmlUnit开发用于测量网页加载时间的代码
下面是我的代码
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);
}
每次我在
(我正在比较两次测试的时间)
我被困在这里,请帮助我