????????????????????????????????????????????????
?????·??
????tomcat???????request????????У????漰??cpu??IO???????IO??????cpu??????????У?????????????????????????в?????????????????????????IO???????ù???
????????С = ( (???io??? + ???cpu) / ???cpu time) * cpu????
?????????
???????io????100ms(IO???????????????????????????)?????cpu???10ms??????????????????4?????????????????????????????С?? ((100 + 10 )/10 ) *4 = 44???????????????????????????????????????????????IO????cpu??????
??????????
???????java ????????filter?????????????????request??????????
public class MoniterFilter implements Filter {
@Override
public void doFilter(ServletRequest request?? ServletResponse response??
FilterChain chain) throws IOException??
ServletException {
long start = System.currentTimeMillis();
String params = getQueryString(httpRequest);
try {
chain.doFilter(httpRequest?? httpResponse);
} finally {
logger.info("access url [{}{}]?? cost time [{}] ms )"?? uri??
params?? cost);
}
private String getQueryString(HttpServletRequest req) {
StringBuilder buffer = new StringBuilder("?");
Enumeration<String> emParams = req.getParameterNames();
try {
while (emParams.hasMoreElements()) {
String sParam = emParams.nextElement();
String sValues = req.getParameter(sParam);
buffer.append(sParam).append("=").append(sValues).append("&");
}
return buffer.substring(0?? buffer.length() - 1);
} catch (Exception e) {
}
return "";
}
}
??????????????????????IO?????jdk??cglib??
public class DaoInterceptor implements MethodInterceptor {
private static final Logger logger = LoggerFactory.getLogger(DaoInterceptor.class);
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
StopWatch watch = new StopWatch();
watch.start();
Object result = null;
Throwable t = null;
try {
result = invocation.proceed();
} catch (Throwable e) {
t = e == null ? null : e.getCause();
throw e;
} finally {
watch.stop();
logger.info("({}ms)"?? watch.getTotalTimeMillis());
}
return result;
}
}
????????????????????????????????????????С????
??????????????????????????????????£????????????????????loadrunner??jmeter???????·?????????????qps???????????????????????С??