【发布时间】:2016-12-06 03:10:02
【问题描述】:
相同的 POJO 代码使用非常基本的 JDK 数学 api,与持久层无关,只是 POJO,但是迭代可能会进行数百万轮,因此从 Websphere 到 Tomcat 的总时间差可能是 10:1。代码是这样的。
for(int i=0;i<200000;i++){
logger.info("calculate result 1");
int result_int1 = new Double(param1_double_left / param1_double_right).intValue();
logger.info("calculate result 2");
int result_int2 = new Double(param2_double_left / param2_double_right).intValue();
logger.info("calculate result 3");
int result_int3 = new Double(param3_double_left / param3_double_right).intValue();
logger.info("calculate result 4");
int result_int4 = new Double(param4_double_left / param4_double_right).intValue();
logger.info("calculate result 5");
int result_int5 = new Double(param5_double_left / param5_double_right).intValue();
//... more calculation with java math like above
}
来自tomcat的log4j日志,速度挺快的,所以时间戳是这样的
2016-12-05 17:53:31,200 INFO .... <-200
.... another 10 - 20 lines with same timestamp
2016-12-05 17:53:31,201 INFO .... <-201
.... another 10 - 20 lines with same timestamp
2016-12-05 17:53:31,202 INFO .... <-202
.... another 10 - 20 lines with same timestamp
2016-12-05 17:53:31,203 INFO .... <-203
.... another 10 - 20 lines with same timestamp
2016-12-05 17:53:31,204 INFO .... <-204
.... another 10 - 20 lines with same timestamp
来自 websphere 的 log4j 日志,时间戳随着每次激增的时间增加而增加
2016-12-05 17:55:47,197 INFO .... <-197
.... another 10 - 20 lines with same timestamp
2016-12-05 17:55:47,212 INFO .... <-212
.... another 10 - 20 lines with same timestamp
2016-12-05 17:55:47,239 INFO .... <-239
.... another 10 - 20 lines with same timestamp
2016-12-05 17:55:47,251 INFO .... <-251
.... another 10 - 20 lines with same timestamp
2016-12-05 17:55:47,277 INFO .... <-277
.... another 10 - 20 lines with same timestamp
所以只是想知道 websphere 运行缓慢的原因可能是什么。 GC?还是其他 JVM 调优?
【问题讨论】:
-
您在每种情况下都使用相同的 JDK 吗?你是如何测量时间的?您是在精确测量 for 循环还是服务器启动时间被拉入?
-
@aguibert 是相同的 JDK (JDK7)。 Tomcat 6 与 Websphere 8.5。我使用 log4j,我可以从 websphere 中看到日志。我已经更新了这个问题,希望可以稍微澄清一下情况。谢谢。
标签: java performance tomcat websphere