< prev index next >

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

Print this page

        

*** 135,140 **** --- 135,174 ---- } tmp = tmp.add(s); } bh.consume(tmp); } + + /** Invokes the shiftLeft method of BigInteger with different values. */ + @Benchmark + @OperationsPerInvocation(TESTSIZE) + public void testLeftShift(Blackhole bh) { + Random rand = new Random(); + int shift = rand.nextInt(30) + 1; + BigInteger tmp = null; + for (BigInteger s : hugeArray) { + if (tmp == null) { + tmp = s; + continue; + } + tmp = tmp.shiftLeft(shift); + } + bh.consume(tmp); + } + + /** Invokes the shiftRight method of BigInteger with different values. */ + @Benchmark + @OperationsPerInvocation(TESTSIZE) + public void testRightShift(Blackhole bh) { + Random rand = new Random(); + int shift = rand.nextInt(30) + 1; + BigInteger tmp = null; + for (BigInteger s : hugeArray) { + if (tmp == null) { + tmp = s; + continue; + } + tmp = tmp.shiftRight(shift); + } + bh.consume(tmp); + } }
< prev index next >