JDK1.5在adm+64位linux上的测试结果, 太意外了!

steeven 2004-11-24 09:01:29
windows amd64
testInt: 610
testLong: 859
testFloat: 1406
testDouble: 953
testConstruct: 2985
testException: 3547
testRandom: 7328

linux fodora 3 amd64
testInt: 8
testLong: 7
testFloat: 7
testDouble: 7
testConstruct: 3420
testException: 2867
testRandom: 1916

配置:amd3000+64/512Ram/
windowsxpSP2 32bit + jdk1.5 for windows 32bit
redhat Fedora 3 + jdk1.5 64bit for linux

float比double慢, linux下面算术运算好像没花时间.
...全文
1031 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
BillionDegree 2004-12-23
  • 打赏
  • 举报
回复

32位windows没有对64位计算的支持。但linux有对64位计算的支持。
你改用64位Windows试试
redex 2004-11-30
  • 打赏
  • 举报
回复
linux下的代码可能被优化过了。
喝酒吃肉 2004-11-30
  • 打赏
  • 举报
回复
windows这么次?
jspxnet 2004-11-30
  • 打赏
  • 举报
回复
不知道java 和 数据库的连接统计计算与.net 和 数据库的连接计算时间上会有多大不同.


hvbird 2004-11-29
  • 打赏
  • 举报
回复
有意思
steeven 2004-11-29
  • 打赏
  • 举报
回复
自己up一下
steeven 2004-11-27
  • 打赏
  • 举报
回复
没有高人知道吗???
Jiazi840207 2004-11-26
  • 打赏
  • 举报
回复
3G是指的CPU的时钟频率,而我们通常说的运算速度是指每秒做的浮点运算次数...
steeven 2004-11-25
  • 打赏
  • 举报
回复
测试代码就在上面.

我也搞不懂,如果7ms执行一亿次循环, 那1sec应该执行140亿的循环.
而且,每次循环里面要i++, 判断i<count, 两次乘法, 一次加法, 一次附值.
加起来大概1000亿次cpu运算了. cpu应该是100G了!

实际上只是3G, 64位运算按照预想只能提高一倍性能而已.

请高手指点迷津.
sourceid 2004-11-25
  • 打赏
  • 举报
回复
这个TestCase类在哪?想测试.
linlow 2004-11-24
  • 打赏
  • 举报
回复
太具有诱惑力了
youngby 2004-11-24
  • 打赏
  • 举报
回复
BU DONG
steeven 2004-11-24
  • 打赏
  • 举报
回复
测试代码: 有疑惑的可以post代码我来运行
import java.util.Random;

import junit.framework.TestCase;

/*
* Created on 2004-11-24
* @author steeven
* <pre>windows amd64
testInt: 610
testLong: 859
testFloat: 1406
testDouble: 953
testConstruct: 2985
testException: 3547
testRandom: 7328
</pre>
<pre>linux fodora 3 amd64
testInt: 8
testLong: 7
testFloat: 7
testDouble: 7
testConstruct: 3420
testException: 2867
testRandom: 1916
</pre>
*/
public class Performance extends TestCase{

private static long start;
int count = (int)1e8;
int count1 = (int)1e6;

public static void main(String[] args) {
}

public void setUp() {
start = System.currentTimeMillis();
}

public void cleanUp() {
StackTraceElement[] traces = Thread.currentThread().getStackTrace();
String item = traces[3].getMethodName();
start = System.currentTimeMillis() - start;
System.out.println(item+":\t" + start);
}

public void testInt() {
int a = 12345;
for (int i = 0; i < count; i++) {
a = a * i + a *a;
}
cleanUp();
}
public void testLong() {

long a = 12345L;
for (int i = 0; i < count; i++) {
a = a * i + a *a;
}
cleanUp();
}
public void testFloat() {

float a = 12345.6789F;
for (int i = 0; i < count; i++) {
a = a * i + a *a;
}
cleanUp();
}
public void testDouble() {

double a = 12345.6789D;
for (int i = 0; i < count; i++) {
a = a * i + a *a;
}
cleanUp();
}
public void testConstruct() {

Performance a = null;
for (int i = 0; i < count; i++) {
a = new Performance();
}
cleanUp();
}
public void testException() {


for (int i = 0; i < count1; i++) {
try {
throw new Exception("test");
} catch (Exception e) {
}
}
cleanUp();
}
public void testRandom() {

Random a = new Random(System.currentTimeMillis());
for (int i = 0; i < count; i++) {
a.nextLong();
}
cleanUp();
}

}

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧