Fixed performance tests.

This commit is contained in:
Alexander Nozik 2019-01-21 17:01:11 +03:00
parent 6154588534
commit 2b4419823b
2 changed files with 27 additions and 10 deletions

View File

@ -30,12 +30,14 @@ fun main() {
//commons-math //commons-math
val cmSolver = CMMatrixContext val cmContext = CMMatrixContext
val commonsTime = measureTimeMillis { val commonsTime = measureTimeMillis {
cmContext.run {
val cm = matrix.toCM() //avoid overhead on conversion val cm = matrix.toCM() //avoid overhead on conversion
repeat(n) { repeat(n) {
val res = cmSolver.inverse(cm) val res = inverse(cm)
}
} }
} }
@ -50,7 +52,7 @@ fun main() {
komaContext.run { komaContext.run {
val km = matrix.toKoma() //avoid overhead on conversion val km = matrix.toKoma() //avoid overhead on conversion
repeat(n) { repeat(n) {
val res = cmSolver.inverse(km) val res = inverse(km)
} }
} }
} }

View File

@ -1,5 +1,6 @@
package scientifik.kmath.linear package scientifik.kmath.linear
import koma.matrix.ejml.EJMLMatrixFactory
import kotlin.random.Random import kotlin.random.Random
import kotlin.system.measureTimeMillis import kotlin.system.measureTimeMillis
@ -13,6 +14,7 @@ fun main() {
// //warmup // //warmup
// matrix1 dot matrix2 // matrix1 dot matrix2
CMMatrixContext.run {
val cmMatrix1 = matrix1.toCM() val cmMatrix1 = matrix1.toCM()
val cmMatrix2 = matrix2.toCM() val cmMatrix2 = matrix2.toCM()
@ -21,6 +23,19 @@ fun main() {
} }
println("CM implementation time: $cmTime") println("CM implementation time: $cmTime")
}
KomaMatrixContext(EJMLMatrixFactory()).run {
val komaMatrix1 = matrix1.toKoma()
val komaMatrix2 = matrix2.toKoma()
val komaTime = measureTimeMillis {
komaMatrix1 dot komaMatrix2
}
println("Koma-ejml implementation time: $komaTime")
}
val genericTime = measureTimeMillis { val genericTime = measureTimeMillis {
val res = matrix1 dot matrix2 val res = matrix1 dot matrix2