您现在的位置是:主页 > news > 海淀重庆网站建设/网店运营工资一般多少
海淀重庆网站建设/网店运营工资一般多少
admin2025/6/26 9:35:19【news】
简介海淀重庆网站建设,网店运营工资一般多少,web实用网站开发实验报告,手机上怎么建网站The following code proves that method1 is faster than method2不,它不能证明这一点.这取决于很多因素.当我运行此代码时,我得到了14031248所以在我的环境中,你的代码“证明”method1比method2慢.在进行基准测试时,您需要注意缓存和JVM预热等效果.也可以看看欲获得更多信息.我…
The following code proves that method1 is faster than method2
不,它不能证明这一点.
这取决于很多因素.当我运行此代码时,我得到了
1403
1248
所以在我的环境中,你的代码“证明”method1比method2慢.
在进行基准测试时,您需要注意缓存和JVM预热等效果.
也可以看看
欲获得更多信息.
我稍微重构了主要方法:
...
static void doBenchmark() {
Trial t = new Trial();
long startTime1 = System.currentTimeMillis();
t.method1();
long endTime1 = System.currentTimeMillis();
long startTime2 = System.currentTimeMillis();
t.method2();
long endTime2 = System.currentTimeMillis();
System.out.println(endTime1 - startTime1);
System.out.println(endTime2 - startTime2);
}
public static void main(String args[]) {
for (int i = 0; i < 20; i++) {
doBenchmark();
System.out.println("----");
}
}
这导致for循环的第一次迭代具有相似的值,但随后结果收敛并且不再显着不同:
1396
1133
----
1052
1070
----
688
711
----
728
726
----
715
709
----
...
甚至,有时方法1似乎更快,有时方法2 – 这很可能是由于测量不准确.