Measuring performance changes from applying 4837946 patch (original) (raw)

Brian Burkhalter brian.burkhalter at oracle.com
Tue Jun 4 17:44:39 UTC 2013


Hi Sergey,

On Jun 4, 2013, at 6:49 AM, Sergey Kuksenko wrote:

could you show your benchmark?

Please see code below.

My quick experiments show that current Karatsuba threshold is quite reasonable.

I hope that you are correct. I would like to know why I am seeing such different numbers.

Thanks,

Brian

/**

import java.math.BigInteger; import java.util.Random; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.BenchmarkType; import org.openjdk.jmh.annotations.GenerateMicroBenchmark; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State;

public class BigIntegerBench {

static final int BITS_KARATSUBA = 1600;
static final int BITS_TOOM_COOK = 2400;
static final int BITS_KARATSUBA_SQUARE = 2880;
static final int BITS_TOOM_COOK_SQUARE = 4480;

static final int BITS_GENERIC = 1600;

@State(Scope.Benchmark)
public static class BenchmarkState {
    Random random = new Random(42L);
    BigInteger genericFactor1 = new BigInteger(BITS_GENERIC + 1, random);
    BigInteger genericFactor2 = new BigInteger(BITS_GENERIC + 400, random);

@OutputTimeUnit(TimeUnit.MICROSECONDS)
@GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
public BigInteger multiplyStandardGeneric(BenchmarkState state) {
    return state.genericFactor1.multiply_standard(state.genericFactor2);
}

@OutputTimeUnit(TimeUnit.MICROSECONDS)
@GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
public BigInteger multiplyKaratsubaGeneric(BenchmarkState state) {
    return state.genericFactor1.multiply_karatsuba(state.genericFactor2);
}

@OutputTimeUnit(TimeUnit.MICROSECONDS)
@GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
public BigInteger multiplyToomCookGeneric(BenchmarkState state) {
    return state.genericFactor1.multiply_toom_cook(state.genericFactor2);
}

}



More information about the core-libs-dev mailing list