Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigInteger;
- import java.util.Random;
- class TestCase2 {
- BigInteger bigI = new BigInteger(1000000000, new Random());
- boolean[] boo = new boolean[1000000000];
- public static void main(String[] args){
- new TestCase2().go();
- }
- public TestCase2() {}
- public void go() {
- long nano2 = System.nanoTime();
- int runs = 0;
- while(runs<10){
- long nano1= System.nanoTime();
- for(long i=0; i<10000000000l;i++){
- bigI.testBit(100);
- }
- System.out.println ((System.nanoTime()-nano1)/1000000000d);
- nano1= System.nanoTime();
- for(long i=0; i<10000000000l;i++){
- boo[100]=true;
- }
- System.out.println ((System.nanoTime()-nano1)/1000000000d);
- nano1= System.nanoTime();
- for(long i=0; i<1000000l;i++){
- for (long o=0; o<10000l; o++){
- boo[100]=true;
- }
- }
- System.out.println ((System.nanoTime()-nano1)/1000000000d);
- nano1= System.nanoTime();
- for(long i=0; i<1000000l;i++){
- for (long o=0; o<10000l; o++){
- bigI.testBit(100);
- }
- }
- System.out.println ((System.nanoTime()-nano1)/1000000000d);
- runs++;
- }
- System.out.println ("total time "+(System.nanoTime()-nano2)/1000000000d);
- }
- }
- 2.514597966
- 2.931126819
- 2.779524721
- 35.625593365
- 2.56806883
- 3.127488276
- 2.783717999
- 35.539277718
- 2.562492128
- 3.127271188
- 2.855650548
- 35.476763574
- 2.50469828
- 3.286902466
- 2.759851302
- 35.591441617
- 3.118894873
- 3.375915328
- 3.05787133
- 35.990224901
- 2.770255478
- 3.156734726
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement