File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
benchmarks/src/jmh/kotlin Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 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 kotlinx.datetime.format.optional
12+ import org.openjdk.jmh.annotations.*
13+ import org.openjdk.jmh.infra.Blackhole
14+ import java.util.concurrent.*
15+
16+ @Warmup(iterations = 5 , time = 1 )
17+ @Measurement(iterations = 5 , time = 1 )
18+ @BenchmarkMode(Mode .AverageTime )
19+ @OutputTimeUnit(TimeUnit .NANOSECONDS )
20+ @State(Scope .Benchmark )
21+ @Fork(1 )
22+ open class ParserStructureConcatBenchmark {
23+
24+ @Benchmark
25+ fun buildFormat (blackhole : Blackhole ) {
26+ val v = LocalDateTime .Format {
27+ year()
28+ char(' -' )
29+ monthNumber()
30+ char(' -' )
31+ day()
32+ char(' ' )
33+ hour()
34+ char(' :' )
35+ minute()
36+ optional {
37+ char(' :' )
38+ second()
39+ optional {
40+ char(' .' )
41+ secondFraction()
42+ }
43+ }
44+ }
45+ blackhole.consume(v)
46+ }
47+ }
You can’t perform that action at this time.
0 commit comments