fork(2) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone {
  9.  
  10. private static final int COUNT = 1000000000;
  11. private static final boolean T = true;
  12. private static final boolean F = false;
  13.  
  14. public static void main (String[] args) throws java.lang.Exception {
  15. // timeLongForm();
  16. timeShortForm();
  17. timeLongForm();
  18. timeShortForm();
  19. // timeLongForm();
  20. }
  21.  
  22. private static void timeLongForm() {
  23. long time = System.currentTimeMillis();
  24. for (int i = 0; i < COUNT; i++) {
  25. boolean answer1 = (T && T) || (!T && !T);
  26. boolean answer2 = (T && F) || (!T && !F);
  27. boolean answer3 = (F && T) || (!F && !T);
  28. boolean answer4 = (F && F) || (!F && !F);
  29. }
  30. long time2 = System.currentTimeMillis();
  31. System.out.println("long: "+(time2-time)+"ms");
  32. }
  33.  
  34. private static void timeShortForm() {
  35. long time = System.currentTimeMillis();
  36. for (int i = 0; i < COUNT; i++) {
  37. boolean answer1 = !(T ^ T);
  38. boolean answer2 = !(F ^ T);
  39. boolean answer3 = !(T ^ F);
  40. boolean answer4 = !(F ^ F);
  41. }
  42. long time2 = System.currentTimeMillis();
  43. System.out.println("short: "+(time2-time)+"ms");
  44. }
  45.  
  46. }
Success #stdin #stdout 3.32s 320576KB
stdin
Standard input is empty
stdout
short: 917ms
long: 1375ms
short: 915ms