Introduce module for benchmarks
diff --git a/benchmark/build.gradle b/benchmark/build.gradle
new file mode 100644
index 0000000..cad8cc9
--- /dev/null
+++ b/benchmark/build.gradle
@@ -0,0 +1,40 @@
+apply plugin: 'java'
+apply plugin: 'kotlin'
+apply plugin: 'kotlinx-serialization'
+apply plugin: 'idea'
+apply plugin: "net.ltgt.apt"
+apply plugin: "com.github.johnrengelman.shadow"
+apply plugin: "me.champeau.gradle.jmh"
+
+sourceCompatibility = 1.8
+targetCompatibility = 1.8
+jmh.jmhVersion = 1.21
+
+jmhJar {
+ baseName 'benchmarks'
+ classifier = null
+ version = null
+}
+
+dependencies {
+ apt 'com.google.auto.value:auto-value:1.4.1'
+ apt 'com.ryanharter.auto.value:auto-value-gson:0.4.6'
+ apt 'com.ryanharter.auto.value:auto-value-moshi:0.4.3'
+
+ compileOnly 'com.google.auto.value:auto-value:1.4.1'
+ compileOnly 'com.ryanharter.auto.value:auto-value-gson:0.4.6'
+ compileOnly 'com.ryanharter.auto.value:auto-value-moshi:0.4.3'
+
+ compile "org.openjdk.jmh:jmh-core:1.21"
+ compile 'com.google.guava:guava:22.0'
+
+ compile 'com.squareup.okio:okio:1.13.0'
+ compile 'com.squareup.moshi:moshi:1.5.0'
+ compile 'com.google.code.gson:gson:2.8.1'
+ compile 'com.esotericsoftware:kryo:4.0.0'
+
+ compile project(':jvm')
+
+ // async profiler
+ compile group: 'pl.project13.scala', name: 'sbt-jmh-extras', version: '0.3.3'
+}
diff --git a/benchmark/src/jmh/kotlin/kotlinx/benchmarks/SampleBenchmark.kt b/benchmark/src/jmh/kotlin/kotlinx/benchmarks/SampleBenchmark.kt
new file mode 100644
index 0000000..03057ee
--- /dev/null
+++ b/benchmark/src/jmh/kotlin/kotlinx/benchmarks/SampleBenchmark.kt
@@ -0,0 +1,25 @@
+package kotlinx.benchmarks
+
+import kotlinx.serialization.*
+import kotlinx.serialization.json.*
+import org.openjdk.jmh.annotations.*
+import java.util.concurrent.*
+
+@Warmup(iterations = 5, time = 1)
+@Measurement(iterations = 5, time = 1)
+@BenchmarkMode(Mode.Throughput)
+@OutputTimeUnit(TimeUnit.MICROSECONDS)
+@State(Scope.Benchmark)
+@Fork(2)
+open class SampleBenchmark {
+
+ @Serializable
+ data class Pojo(val a: Int)
+
+ private val value = Pojo(1)
+
+ @Benchmark
+ fun benchmarkStringify(): String {
+ return JSON.stringify(value)
+ }
+}
diff --git a/build.gradle b/build.gradle
index ca6a726..1de27b2 100644
--- a/build.gradle
+++ b/build.gradle
@@ -30,6 +30,7 @@
repositories {
jcenter()
mavenLocal()
+ maven { url "https://plugins.gradle.org/m2/" }
maven { url eapChannel }
maven { url serializationRepo }
}
@@ -37,10 +38,11 @@
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$compilerVersion"
classpath "org.jetbrains.kotlinx:kotlinx-gradle-serialization-plugin:$serializationPluginVersion"
-
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.2'
-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
+ classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2"
+ classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.5"
+ classpath "net.ltgt.gradle:gradle-apt-plugin:0.10"
}
}
diff --git a/settings.gradle b/settings.gradle
index 23ff320..18de8fd 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -20,8 +20,10 @@
include ':jvm'
include ':js'
include ':configparser'
+include ':benchmark'
project(':common').projectDir = file('./runtime/common')
project(':jvm').projectDir = file('./runtime/jvm')
project(':js').projectDir = file('./runtime/js')
project(':configparser').projectDir = file('./formats/config')
+project(':benchmark').projectDir = file('./benchmark')