Java JRE与GCJ [英] Java JRE vs GCJ

查看:178
本文介绍了Java JRE与GCJ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用Java编写的速度测试得到了这个结果:

  Java 

real 0m20.626s
用户0m20.257s
sys 0m0.244s

GCJ

实际3m10.567s
用户3m5.168s
sys 0m0.676s

那么,GCJ的目的是什么呢?有了这个结果,我确定我不打算用GCJ编译它!



我在Linux上测试了这个,Windows中的结果可能比那更好吗? / p>

这是应用程序的代码:

  public static void main (String [] args){
String str =;
System.out.println(Start !!!);
for(long i = 0; i< 5000000L; i ++){
Math.sqrt((double)i);
Math.pow((double)i,2.56);
long j = i * 745L;
String string = new String(String.valueOf(i));
string = string.concat(kaka pipi); //Kaka pipi是荷兰人的一种小孩叫。
string = new String(string.toUpperCase());
if(i%300 == 0){
str =;
} else {
str + = Long.toHexString(i);
}
}
System.out.println(停止!!!);
}

我用GCJ编译如下:

  gcj -c -g -O Main.java 
gcj --main = speedtest.Main -o Exec Main.o

并按以下方式运行:

 时间./Exec //对于GCJ 
时间java -jar SpeedTest.jar //对于Java


解决方案

GCJ已经过时了。它是很久以前开始的,因为人们想要一个开源替代Sun JDK,它从来没有特别好。既然Sun公开了他们的JDK,那么绝对没有理由使用GCJ(但它仍然潜伏在一些Linux发行版中)。


I have this results from a speed test I wrote in Java:

Java

real        0m20.626s
user        0m20.257s
sys         0m0.244s

GCJ

real        3m10.567s
user        3m5.168s
sys         0m0.676s

So, what is the purpose of GCJ then? With this results I'm sure I'm not going to compile it with GCJ!

I tested this on Linux, are the results in Windows maybe better than that?

This was the code from the application:

public static void main(String[] args) {
    String str = "";
    System.out.println("Start!!!");
    for (long i = 0; i < 5000000L; i++) {
        Math.sqrt((double) i);
        Math.pow((double) i, 2.56);
        long j = i * 745L;
        String string = new String(String.valueOf(i));
        string = string.concat(" kaka pipi"); // "Kaka pipi" is a kind of childly call in Dutch. 
        string = new String(string.toUpperCase());
        if (i % 300 == 0) {
            str = "";
        } else {
            str += Long.toHexString(i);
        }
    }
    System.out.println("Stop!!!");
}

I compiled with GCJ like this:

gcj -c -g -O Main.java
gcj --main=speedtest.Main -o Exec Main.o

And ran like this:

time ./Exec                     // For GCJ
time java -jar SpeedTest.jar    // For Java

解决方案

GCJ is obsolete. It was started a long time ago because people wanted an open-source alternative to the Sun JDK, and it was never particularly good. Now that Sun open-sourced their JDK, there's absolutely no reason to use GCJ (but it still lurks in some Linux distros).

这篇关于Java JRE与GCJ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆