Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is there a huge performance difference between 32 and 64 bit JDK?
    primarykey
    data
    text
    <p>So I've been doing Project Euler, and I found two ways to solve Problem 57. However, there seems to be a huge difference in performance between using a 32bit JDK and a 64bit JDK. </p> <pre><code>public static int fractionSolution (int l){ int count = 0; for (int i = 1; i &lt; l; i++) { BigFraction f = iterateFraction(i).subtract(new BigFraction(1,1)); if(f.getDenominator().toString().length() &lt; 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 &lt; l; i++) { n = n.add(d.multiply(new BigInteger("2"))); d = n.subtract(d); if(n.toString().length() &gt; d.toString().length()){ count++; } } return count; } </code></pre> <p>If I run the fractionSolution on 64 bit JDK, it will take 30 seconds, but on 32bit, it will take 90 seconds. </p> <p>If I run patternSolution on 64 bit JDK, it will take about 80 ms, but on 32 bit, it will take about 40 ms. </p> <p>Why is there such a huge difference between the JDKs? Which one should I use?</p> <p>I'm using Java SE 7, JDK 1.7</p> <p>Here are screen caps of my program so you don't have to run it. <a href="http://imgur.com/elzQMi3,BxEZ1RK,lDo6YBW,rRiaelE#0" rel="nofollow">http://imgur.com/elzQMi3,BxEZ1RK,lDo6YBW,rRiaelE#0</a></p> <p>You can tell which JDK it is from the file paths.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload