< prev index next >

test/micro/org/openjdk/bench/java/math/BigIntegers.java

Print this page




 120             }
 121             tmp = tmp.multiply(s);
 122         }
 123         bh.consume(tmp);
 124     }
 125 
 126     /** Invokes the multiply method of BigInteger with various different values. */
 127     @Benchmark
 128     @OperationsPerInvocation(TESTSIZE)
 129     public void testAdd(Blackhole bh) {
 130         BigInteger tmp = null;
 131         for (BigInteger s : hugeArray) {
 132             if (tmp == null) {
 133                 tmp = s;
 134                 continue;
 135             }
 136             tmp = tmp.add(s);
 137         }
 138         bh.consume(tmp);
 139     }


































 140 }


 120             }
 121             tmp = tmp.multiply(s);
 122         }
 123         bh.consume(tmp);
 124     }
 125 
 126     /** Invokes the multiply method of BigInteger with various different values. */
 127     @Benchmark
 128     @OperationsPerInvocation(TESTSIZE)
 129     public void testAdd(Blackhole bh) {
 130         BigInteger tmp = null;
 131         for (BigInteger s : hugeArray) {
 132             if (tmp == null) {
 133                 tmp = s;
 134                 continue;
 135             }
 136             tmp = tmp.add(s);
 137         }
 138         bh.consume(tmp);
 139     }
 140 
 141     /** Invokes the shiftLeft method of BigInteger with different values. */
 142     @Benchmark
 143     @OperationsPerInvocation(TESTSIZE)
 144     public void testLeftShift(Blackhole bh) {
 145         Random rand = new Random();
 146         int shift = rand.nextInt(30) + 1;
 147         BigInteger tmp = null;
 148         for (BigInteger s : hugeArray) {
 149             if (tmp == null) {
 150                 tmp = s;
 151                 continue;
 152             }
 153             tmp = tmp.shiftLeft(shift);
 154         }
 155         bh.consume(tmp);
 156     }
 157 
 158     /** Invokes the shiftRight method of BigInteger with different values. */
 159     @Benchmark
 160     @OperationsPerInvocation(TESTSIZE)
 161     public void testRightShift(Blackhole bh) {
 162         Random rand = new Random();
 163         int shift = rand.nextInt(30) + 1;
 164         BigInteger tmp = null;
 165         for (BigInteger s : hugeArray) {
 166             if (tmp == null) {
 167                 tmp = s;
 168                 continue;
 169             }
 170             tmp = tmp.shiftRight(shift);
 171         }
 172         bh.consume(tmp);
 173     }
 174 }
< prev index next >