Moved JMH out of core
This commit is contained in:
parent
fb9cc1732b
commit
f506e76b69
@ -1,6 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'kotlin-multiplatform'// version '1.3.0-rc-116'
|
id 'kotlin-multiplatform'
|
||||||
id "me.champeau.gradle.jmh" version "0.4.7"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@ -8,14 +7,9 @@ repositories {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies{
|
|
||||||
jmh 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
targets {
|
targets {
|
||||||
fromPreset(presets.jvmWithJava, 'jvm')
|
fromPreset(presets.jvm, 'jvm')
|
||||||
//fromPreset(presets.jvm, 'jvm')
|
|
||||||
fromPreset(presets.js, 'js')
|
fromPreset(presets.js, 'js')
|
||||||
// For ARM, preset should be changed to presets.iosArm32 or presets.iosArm64
|
// For ARM, preset should be changed to presets.iosArm32 or presets.iosArm64
|
||||||
// For Linux, preset should be changed to e.g. presets.linuxX64
|
// For Linux, preset should be changed to e.g. presets.linuxX64
|
||||||
|
15
kmath-jmh/build.gradle
Normal file
15
kmath-jmh/build.gradle
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
plugins {
|
||||||
|
id "java"
|
||||||
|
id "kotlin"
|
||||||
|
id "me.champeau.gradle.jmh" version "0.4.7"
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven { url = 'http://dl.bintray.com/kotlin/kotlin-eap' }
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation project(':kmath-core')
|
||||||
|
jmh 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package scientifik.kmath.structures
|
||||||
|
|
||||||
|
import org.openjdk.jmh.annotations.*
|
||||||
|
import java.nio.IntBuffer
|
||||||
|
|
||||||
|
|
||||||
|
@Fork(1)
|
||||||
|
@Warmup(iterations = 2)
|
||||||
|
@Measurement(iterations = 5)
|
||||||
|
@State(Scope.Benchmark)
|
||||||
|
open class ArrayBenchmark {
|
||||||
|
|
||||||
|
lateinit var array: IntArray
|
||||||
|
lateinit var arrayBuffer: IntBuffer
|
||||||
|
lateinit var nativeBuffer: IntBuffer
|
||||||
|
|
||||||
|
@Setup
|
||||||
|
fun setup() {
|
||||||
|
array = IntArray(10000) { it }
|
||||||
|
arrayBuffer = IntBuffer.wrap(array)
|
||||||
|
nativeBuffer = IntBuffer.allocate(10000)
|
||||||
|
for (i in 0 until 10000) {
|
||||||
|
nativeBuffer.put(i,i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
fun benchmarkArrayRead() {
|
||||||
|
var res = 0
|
||||||
|
for (i in 1..10000) {
|
||||||
|
res += array[10000 - i]
|
||||||
|
}
|
||||||
|
print(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
fun benchmarkBufferRead() {
|
||||||
|
var res = 0
|
||||||
|
for (i in 1..10000) {
|
||||||
|
res += arrayBuffer.get(10000 - i)
|
||||||
|
}
|
||||||
|
print(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
fun nativeBufferRead() {
|
||||||
|
var res = 0
|
||||||
|
for (i in 1..10000) {
|
||||||
|
res += nativeBuffer.get(10000 - i)
|
||||||
|
}
|
||||||
|
print(res)
|
||||||
|
}
|
||||||
|
}
|
@ -10,4 +10,5 @@ enableFeaturePreview('GRADLE_METADATA')
|
|||||||
|
|
||||||
rootProject.name = 'kmath'
|
rootProject.name = 'kmath'
|
||||||
include ':kmath-core'
|
include ':kmath-core'
|
||||||
|
include ':kmath-jmh'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user