建议i3cpu以上的测试
public class PaoFen {
public static void main(String[] args) {
System.out.println("现在开始测试性能");
long sta = System.currentTimeMillis();
System.out.println("正在测试整数运算");
for (int i = 0; i < 1000000; i++) {
for (int j = 0; j < 10000; j++) {
for (int j2 = 0; j2 < 3000; j2++) {
}
}
}
long s = System.currentTimeMillis();
System.out.println("整数运算为" + (100000 - (s - sta)) + "分");
System.out.println("正在测试单精度浮点运算");
for (float i = 1; i < 16000000; i++) {
}
long e = System.currentTimeMillis();
System.out.println("单精度浮点运算为" + (10000 - (e - s)) + "分");
System.out.println("正在测试双精度浮点运算");
for (double i = 1.0; i < 1000000000.0; i++) {
}
long end = System.currentTimeMillis();
System.out.println("双精度浮点运算为" + (10000 - (end - e)) + "分");
}
}
|
|