forked from kscience/kmath
Update BigIntBenchmark.kt
unify definition (pow function seems to work wrong
This commit is contained in:
parent
41d0be8085
commit
3dc7038b6e
@ -12,16 +12,17 @@ import org.openjdk.jmh.annotations.Scope
|
|||||||
import org.openjdk.jmh.annotations.State
|
import org.openjdk.jmh.annotations.State
|
||||||
import space.kscience.kmath.operations.*
|
import space.kscience.kmath.operations.*
|
||||||
|
|
||||||
|
|
||||||
|
private fun BigInt.pow(power: Int): BigInt = modPow(BigIntField.number(power), BigInt.ONE)
|
||||||
|
|
||||||
|
|
||||||
@State(Scope.Benchmark)
|
@State(Scope.Benchmark)
|
||||||
internal class BigIntBenchmark {
|
internal class BigIntBenchmark {
|
||||||
|
|
||||||
val kmNumber = BigIntField.number(Int.MAX_VALUE)
|
val kmNumber = BigIntField.number(Int.MAX_VALUE)
|
||||||
val largeKmNumber = BigIntField {
|
|
||||||
fun BigInt.pow10(): BigInt = power(10, ::multiply)
|
|
||||||
number(11).pow10().pow10().pow10().pow10().pow10()
|
|
||||||
}
|
|
||||||
val jvmNumber = JBigIntegerField.number(Int.MAX_VALUE)
|
val jvmNumber = JBigIntegerField.number(Int.MAX_VALUE)
|
||||||
val largeJvmNumber = JBigIntegerField { number(11).pow(100_000) }
|
val largeKmNumber = BigIntField { number(11).pow(100_000) }
|
||||||
|
val largeJvmNumber = JBigIntegerField { number(11).pow(100_000) }
|
||||||
val bigExponent = 50_000
|
val bigExponent = 50_000
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
@ -41,7 +42,7 @@ internal class BigIntBenchmark {
|
|||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
fun kmMultiplyLarge(blackhole: Blackhole) = BigIntField {
|
fun kmMultiplyLarge(blackhole: Blackhole) = BigIntField {
|
||||||
blackhole.consume(largeKmNumber.let { it * it })
|
blackhole.consume(largeKmNumber*largeKmNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
@ -51,12 +52,12 @@ internal class BigIntBenchmark {
|
|||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
fun jvmMultiplyLarge(blackhole: Blackhole) = JBigIntegerField {
|
fun jvmMultiplyLarge(blackhole: Blackhole) = JBigIntegerField {
|
||||||
blackhole.consume(largeJvmNumber.let { it * it })
|
blackhole.consume(largeJvmNumber*largeJvmNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
fun kmPower(blackhole: Blackhole) = BigIntField {
|
fun kmPower(blackhole: Blackhole) = BigIntField {
|
||||||
blackhole.consume(kmNumber.power(bigExponent, ::multiply))
|
blackhole.consume(kmNumber.pow(bigExponent))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
|
Loading…
Reference in New Issue
Block a user