为什么32位和64位JDK之间存在巨大的性能差异?

use*_*445 9 java performance

所以我一直在做Project Euler,我找到了两种解决问题57的方法.但是,使用32位JDK和64位JDK之间的性能似乎有很大差异.

public static int fractionSolution (int l){
int count = 0;
for (int i = 1; i < l; i++) {
    BigFraction f = iterateFraction(i).subtract(new BigFraction(1,1));
    if(f.getDenominator().toString().length() < f.getNumerator().toString().length()){
        count++;
    }
}
return count;
}

public static BigFraction iterateFraction(int n){
    if(n==1){
        return new BigFraction(2.5);
    }
    else{
        BigFraction base = new BigFraction(1,1);
        BigFraction two = new BigFraction(2,1);
        return two.add(base.divide(iterateFraction(n-1)));
    }
}

public static int patternSolution (int l){
    BigInteger n = new BigInteger("3");
    BigInteger d = new BigInteger("2");
    int count = 0;
    for (int i = 1; i < l; i++) {
        n = n.add(d.multiply(new BigInteger("2")));
        d = n.subtract(d);
        if(n.toString().length() > d.toString().length()){
            count++;
        }
    }
    return count;
}
Run Code Online (Sandbox Code Playgroud)

如果我在64位JDK上运行fractionSolution,则需要30秒,但在32位时,需要90秒.

如果我在64位JDK上运行patternSolution,它将花费大约80毫秒,但在32位上,它将花费大约40毫秒.

为什么JDK之间存在如此巨大的差异?我应该使用哪一个?

我正在使用Java SE 7,JDK 1.7

这是我的程序的屏幕上限,所以你不必运行它. http://imgur.com/elzQMi3,BxEZ1RK,lDo6YBW,rRiaelE#0

您可以从文件路径中分辨出它是哪个JDK.