File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
benchmarks/src/jmh/kotlin Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -41,4 +41,48 @@ open class ParallelFormatBenchmark {
4141 }
4242 blackhole.consume(format)
4343 }
44+
45+ @Benchmark
46+ fun formatCreationWithNestedAlternativeParsing (blackhole : Blackhole ) {
47+ val format = LocalDateTime .Format {
48+ repeat(n) { index ->
49+ alternativeParsing(
50+ { monthNumber(); char(' -' ); day() },
51+ { day(); char(' /' ); monthNumber() },
52+ primaryFormat = { year(); char(' -' ); monthNumber(); char(' -' ); day() }
53+ )
54+
55+ if (index % 2 == 0 ) {
56+ alternativeParsing(
57+ {
58+ alternativeParsing(
59+ { hour(); char(' :' ); minute() },
60+ { minute(); char(' :' ); second() },
61+ primaryFormat = { hour(); char(' :' ); minute(); char(' :' ); second() }
62+ )
63+ },
64+ primaryFormat = {
65+ year(); char(' -' ); monthNumber(); char(' -' ); day()
66+ char(' T' )
67+ hour(); char(' :' ); minute(); char(' :' ); second()
68+ }
69+ )
70+ }
71+
72+ char(' |' )
73+ if (index % 3 == 0 ) {
74+ char(' |' )
75+ }
76+
77+ if (index < 8 ) {
78+ alternativeParsing(
79+ { char(' Z' ) },
80+ { char(' +' ); hour(); char(' :' ); minute() },
81+ primaryFormat = { char(' -' ); hour(); char(' :' ); minute() }
82+ )
83+ }
84+ }
85+ }
86+ blackhole.consume(format)
87+ }
4488}
You can’t perform that action at this time.
0 commit comments