Skip to content

Commit bc2a745

Browse files
Move largeSerialFormat benchmark to the separate file
1 parent 39dd457 commit bc2a745

File tree

2 files changed

+46
-24
lines changed

2 files changed

+46
-24
lines changed

benchmarks/src/jmh/kotlin/ParserStructureConcatBenchmark.kt renamed to benchmarks/src/jmh/kotlin/PythonDateTimeFormatBenchmark.kt

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,7 @@ import java.util.concurrent.*
1919
@OutputTimeUnit(TimeUnit.NANOSECONDS)
2020
@State(Scope.Benchmark)
2121
@Fork(1)
22-
open class ParserStructureConcatBenchmark {
23-
24-
@Param("1", "2", "4", "8", "16", "32", "64", "128", "256", "512", "1024")
25-
var n = 0
26-
27-
@Benchmark
28-
fun largeSerialFormat(blackhole: Blackhole) {
29-
val format = LocalDateTime.Format {
30-
repeat(n) {
31-
char('^')
32-
monthNumber()
33-
char('&')
34-
day()
35-
char('!')
36-
hour()
37-
char('$')
38-
minute()
39-
char('#')
40-
second()
41-
char('@')
42-
}
43-
}
44-
blackhole.consume(format)
45-
}
22+
open class PythonDateTimeFormatBenchmark {
4623

4724
@Benchmark
4825
fun buildPythonDateTimeFormat(blackhole: Blackhole) {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2019-2025 JetBrains s.r.o. and contributors.
3+
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
4+
*/
5+
6+
@file:Suppress("unused")
7+
8+
package kotlinx.datetime
9+
10+
import kotlinx.datetime.format.char
11+
import org.openjdk.jmh.annotations.*
12+
import org.openjdk.jmh.infra.Blackhole
13+
import java.util.concurrent.TimeUnit
14+
15+
@Warmup(iterations = 5, time = 1)
16+
@Measurement(iterations = 5, time = 1)
17+
@BenchmarkMode(Mode.AverageTime)
18+
@OutputTimeUnit(TimeUnit.NANOSECONDS)
19+
@State(Scope.Benchmark)
20+
@Fork(1)
21+
open class SerialFormatBenchmark {
22+
23+
@Param("1", "2", "4", "8", "16", "32", "64", "128", "256", "512", "1024")
24+
var n = 0
25+
26+
@Benchmark
27+
fun largeSerialFormat(blackhole: Blackhole) {
28+
val format = LocalDateTime.Format {
29+
repeat(n) {
30+
char('^')
31+
monthNumber()
32+
char('&')
33+
day()
34+
char('!')
35+
hour()
36+
char('$')
37+
minute()
38+
char('#')
39+
second()
40+
char('@')
41+
}
42+
}
43+
blackhole.consume(format)
44+
}
45+
}

0 commit comments

Comments
 (0)