Advertisement
Guest User

Untitled

a guest
Feb 13th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. import java.math.BigInteger;
  2. import java.util.Random;
  3.  
  4. class TestCase2 {
  5.  
  6. BigInteger bigI = new BigInteger(1000000000, new Random());
  7.  
  8. boolean[] boo = new boolean[1000000000];
  9.  
  10.  
  11. public static void main(String[] args){
  12.  
  13.  
  14. new TestCase2().go();
  15.  
  16. }
  17.  
  18.  
  19. public TestCase2() {}
  20.  
  21.  
  22. public void go() {
  23.  
  24. long nano2 = System.nanoTime();
  25. int runs = 0;
  26.  
  27. while(runs<10){
  28.  
  29. long nano1= System.nanoTime();
  30.  
  31. for(long i=0; i<10000000000l;i++){
  32.  
  33. bigI.testBit(100);
  34. }
  35.  
  36. System.out.println ((System.nanoTime()-nano1)/1000000000d);
  37.  
  38.  
  39.  
  40. nano1= System.nanoTime();
  41.  
  42. for(long i=0; i<10000000000l;i++){
  43.  
  44. boo[100]=true;
  45. }
  46.  
  47. System.out.println ((System.nanoTime()-nano1)/1000000000d);
  48.  
  49.  
  50. nano1= System.nanoTime();
  51.  
  52. for(long i=0; i<1000000l;i++){
  53. for (long o=0; o<10000l; o++){
  54. boo[100]=true;
  55. }
  56. }
  57.  
  58. System.out.println ((System.nanoTime()-nano1)/1000000000d);
  59.  
  60.  
  61.  
  62. nano1= System.nanoTime();
  63.  
  64. for(long i=0; i<1000000l;i++){
  65. for (long o=0; o<10000l; o++){
  66. bigI.testBit(100);
  67. }
  68. }
  69.  
  70. System.out.println ((System.nanoTime()-nano1)/1000000000d);
  71.  
  72.  
  73.  
  74. runs++;
  75. }
  76.  
  77. System.out.println ("total time "+(System.nanoTime()-nano2)/1000000000d);
  78.  
  79.  
  80. }
  81. }
  82.  
  83.  
  84.  
  85. 2.514597966
  86. 2.931126819
  87. 2.779524721
  88. 35.625593365
  89. 2.56806883
  90. 3.127488276
  91. 2.783717999
  92. 35.539277718
  93. 2.562492128
  94. 3.127271188
  95. 2.855650548
  96. 35.476763574
  97. 2.50469828
  98. 3.286902466
  99. 2.759851302
  100. 35.591441617
  101. 3.118894873
  102. 3.375915328
  103. 3.05787133
  104. 35.990224901
  105. 2.770255478
  106. 3.156734726
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement