File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
benchmarks/src/jmh/kotlin Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ package kotlinx.datetime
99
1010import kotlinx.datetime.format.DateTimeComponents
1111import kotlinx.datetime.format.DayOfWeekNames
12+ import kotlinx.datetime.format.ISO_DATE
1213import kotlinx.datetime.format.MonthNames
1314import kotlinx.datetime.format.Padding
1415import kotlinx.datetime.format.alternativeParsing
@@ -92,4 +93,37 @@ open class CommonFormats {
9293 val format = DateTimeComponents .Formats .RFC_1123
9394 blackhole.consume(format)
9495 }
96+
97+ @Benchmark
98+ fun buildIsoDateTimeOffsetFormat (blackhole : Blackhole ) {
99+ val format = DateTimeComponents .Format {
100+ date(LocalDate .Format {
101+ year()
102+ char(' -' )
103+ monthNumber()
104+ char(' -' )
105+ day()
106+ })
107+ alternativeParsing({
108+ char(' t' )
109+ }) {
110+ char(' T' )
111+ }
112+ hour()
113+ char(' :' )
114+ minute()
115+ char(' :' )
116+ second()
117+ optional {
118+ char(' .' )
119+ secondFraction(1 , 9 )
120+ }
121+ alternativeParsing({
122+ offsetHours()
123+ }) {
124+ offset(UtcOffset .Formats .ISO )
125+ }
126+ }
127+ blackhole.consume(format)
128+ }
95129}
You can’t perform that action at this time.
0 commit comments