I have written a simple factorial program, with arbitrary precision:
public class Fac {
public static void main(String[] args) {
int stop = 100000;
long start = System.currentTimeMillis();
BigInteger integer = new BigInteger("1");
for(int i = 2; i <= stop; i++){
integer = integer.multiply(new BigInteger(i +""));
}
System.out.println("It took: " + (System.currentTimeMillis() - start) + "ms");
//System.out.println(integer);
}
}
When i run it in IntelliJ:
It took: 5392ms
When i run it in commandline:
It took: 17919ms
The commandline is run by:
javac Fac.java
java Fac
I know this is not the best way to measure time but the gap is soo huge that it does not matter. Why is the performence that different?
Other people has noticed similar difference, however, as far as i can tell, their conclusions seem unrelated to my situation.
Why is my application running faster in IntelliJ compared to command-line?