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)) + "分");
}
} 作者: 火云邪神 时间: 2015-5-13 23:42
我的电脑不敢试作者: gainn 时间: 2015-5-13 23:48
写个算π的运算方法吧,那个可以测试CPU性能。作者: 鸿鹄2008 时间: 2015-5-13 23:48
应该再开几个多线程作者: Oh.Ba 时间: 2015-5-14 00:27