Skip to content

Commit f28e005

Browse files
authored
Json benchmarks (#1337)
* Introduce lightweight twitter-feed benchmark * Introduce benchmark that does a basic comparison with Jackson mapper * Introduce benchmark that stresses primitives parsing * Introduce more macro benchmarks
1 parent 6a8dc86 commit f28e005

15 files changed

+66547
-321
lines changed

.idea/vcs.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

benchmark/build.gradle

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ apply plugin: "me.champeau.gradle.jmh"
88

99
sourceCompatibility = 1.8
1010
targetCompatibility = 1.8
11-
jmh.jmhVersion = 1.21
11+
jmh.jmhVersion = 1.22
1212

1313
if (rootProject.ext.jvm_ir_enabled) {
1414
kotlin.target.compilations.all {
@@ -20,26 +20,15 @@ jmhJar {
2020
baseName 'benchmarks'
2121
classifier = null
2222
version = null
23+
destinationDir = file("$rootDir")
2324
}
2425

2526
dependencies {
26-
annotationProcessor 'com.google.auto.value:auto-value:1.4.1'
27-
annotationProcessor 'com.ryanharter.auto.value:auto-value-gson:0.4.6'
28-
29-
compileOnly 'com.google.auto.value:auto-value:1.4.1'
30-
compileOnly 'com.ryanharter.auto.value:auto-value-gson:0.4.6'
31-
3227
compile "org.openjdk.jmh:jmh-core:1.22"
3328
implementation 'com.google.guava:guava:24.1.1-jre'
34-
35-
compile 'com.squareup.okio:okio:1.13.0'
36-
compile 'com.google.code.gson:gson:2.8.1'
37-
compile 'com.esotericsoftware:kryo:4.0.0'
38-
29+
compile 'com.fasterxml.jackson.core:jackson-databind:2.12.1'
30+
compile 'com.fasterxml.jackson.module:jackson-module-kotlin:2.12.1'
3931
compile project(':kotlinx-serialization-core')
4032
compile project(':kotlinx-serialization-json')
4133
compile project(':kotlinx-serialization-protobuf')
42-
43-
// async profiler
44-
compile group: 'pl.project13.scala', name: 'sbt-jmh-extras', version: '0.3.3'
4534
}

benchmark/src/jmh/kotlin/kotlinx/benchmarks/SampleBenchmark.kt

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package kotlinx.benchmarks.json
2+
3+
import kotlinx.benchmarks.model.*
4+
import kotlinx.serialization.json.*
5+
import org.openjdk.jmh.annotations.*
6+
import java.util.concurrent.*
7+
8+
@Warmup(iterations = 7, time = 1)
9+
@Measurement(iterations = 7, time = 1)
10+
@BenchmarkMode(Mode.Throughput)
11+
@OutputTimeUnit(TimeUnit.SECONDS)
12+
@State(Scope.Benchmark)
13+
@Fork(2)
14+
open class CitmBenchmark {
15+
/*
16+
* For some reason Citm is kind of de-facto standard cross-language benchmark.
17+
* Order of magnitude: 200 ops/sec
18+
*/
19+
private val citm = CitmBenchmark::class.java.getResource("/citm_catalog.json").readBytes().decodeToString()
20+
21+
@Benchmark
22+
fun decodeCitm(): CitmCatalog = Json.decodeFromString(CitmCatalog.serializer(), citm)
23+
}

benchmark/src/jmh/kotlin/kotlinx/benchmarks/json/GeneratedBenchmark.kt

Lines changed: 0 additions & 281 deletions
This file was deleted.

0 commit comments

Comments
 (0)