fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.math.BigDecimal;
  7. import java.math.BigInteger;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. BigInteger limit = new BigInteger("10000");
  15. long l = System.currentTimeMillis();
  16. for (BigInteger i = BigInteger.ONE; i.compareTo(limit) < 0; i = i.add(BigInteger.ONE))
  17. {
  18. BigDecimal temp = new BigDecimal(0);
  19. }
  20. long l1 = System.currentTimeMillis();
  21. BigDecimal temp1;
  22. for (BigInteger i = BigInteger.ONE; i.compareTo(limit) < 0; i = i.add(BigInteger.ONE))
  23. {
  24. temp1 = new BigDecimal(0);
  25. }
  26. long l2 = System.currentTimeMillis();
  27. System.out.println("1st loop time: "+(l1-l)/1000.0);
  28. System.out.println("2nd loop time: "+(l2-l1)/1000.0);
  29. }
  30. }
Success #stdin #stdout 0.06s 2184192KB
stdin
Standard input is empty
stdout
1st loop time: 0.011
2nd loop time: 0.002