0
에서 웹 사이트의 응답 시간을 계산합니다. 당신이 HTTP 요청과 응답 사이의 왕복을 계산하려면는 어떻게 응답 또는 전체로드 시간에 웹 사이트에서 걸리는 시간을 계산해야 system.I 웹 사이트 모니터링 구축을 위해 노력하고 자바
에서 웹 사이트의 응답 시간을 계산합니다. 당신이 HTTP 요청과 응답 사이의 왕복을 계산하려면는 어떻게 응답 또는 전체로드 시간에 웹 사이트에서 걸리는 시간을 계산해야 system.I 웹 사이트 모니터링 구축을 위해 노력하고 자바
, 당신은 apache http components를 사용할 수 있습니다. 이것은 apache http client라고 불리곤했습니다.
는 여기에 내가 요청을 위해 사용하고 일부 샘플 코드입니다. 요청 전후에 타임 스탬프를 잡을 수 있습니다.
는HttpClient httpclient = new DefaultHttpClient();
URIBuilder builder = new URIBuilder();
URI uri = null;
HttpEntity entity = null;
InputStream inputStream = null;
JSONObject jsonObject = null;
URL url = this.getClass().getClassLoader().getResource("json" + File.separator + "newInstall.json");
try {
String json = FileUtil.readFile(url.getPath());
builder.setScheme("http").setHost(host).setPort(8080).setPath(basePath + authResource)
.setParameter("sig", "sig").setParameter("params", json);
uri = builder.build();
log.info("uri: {}", uri);
HttpGet httpget = new HttpGet(uri);
HttpResponse response = httpclient.execute(httpget);
entity = response.getEntity();
if (entity != null) {
inputStream = entity.getContent();
String jsonString = IOUtils.toString(inputStream, "UTF-8");
jsonObject = new JSONObject(jsonString);
log.info("auth response: {}", jsonString);
}
} catch (Exception e) {
log.error("error", e);
}finally {
if(inputStream != null) {
try {
inputStream.close();
}catch(Exception ex) {
log.error("error closing input stream", ex);
}
}
}
당신은 무엇을 시도? 이 문제와 관련하여 도움이되는 도구 나 기타 도구를 조사 했습니까? –