Daugilas

3-n

Jun 16th, 2021
584
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rounds = 2000000000;
  2.  
  3. console.log('3-n');
  4. tStart = Date.now();
  5. n = 2;
  6. for (i = rounds; i--; i<0) n=3-n;
  7. tEnd = Date.now();
  8. console.log('n = '+ n + '; duration = ' + (tEnd - tStart));
  9.  
  10. console.log('3^n');
  11. tStart = Date.now();
  12. n = 2;
  13. //for (i = rounds; i--; i<0) n=3^n;
  14. tEnd = Date.now();
  15. console.log('n = '+ n + '; duration = ' + (tEnd - tStart));
  16.  
  17. console.log('?');
  18. tStart = Date.now();
  19. n = 2;
  20. //for (i = rounds; i--; i<0) n = n==1 ? 2:1;
  21. tEnd = Date.now();
  22. console.log('n = '+ n + '; duration = ' + (tEnd - tStart));
  23.  
  24. console.log('if');
  25. tStart = Date.now();
  26. n = 2;
  27. //for (i = rounds; i--; i<0) if (n==1) {n = 2;} else {n = 1};
  28. tEnd = Date.now();
  29. console.log('n = '+ n + '; duration = ' + (tEnd - tStart));
  30.  
  31.  
  32. console.log('While');
  33.  
  34. console.log('3-n');
  35. tStart = Date.now();
  36. n = 2;
  37. i = rounds;
  38. while (i>0) { n=3-n; i--; }
  39. tEnd = Date.now();
  40. console.log('n = '+ n + '; duration = ' + (tEnd - tStart));
  41.  
RAW Paste Data