On Wed, 4 Oct 2023 22:30:42 GMT, Shaojin Wen <d...@openjdk.org> wrote:
> # Goal > Improve String Template FMT's processing performance of date types. > Currently, FMT processes date types by toString and then calls > j.u.Formatter#print. Because there is less parse processing than > String.format, the performance is improved, but it is still not good enough. > There is an intermediate String object allocation, and the print performance > of j.u.Formatter is not as good as The StringConcat.prepend method is great. > > This patch allows String Template FMT to handle > Date/Instant/LocalDate/LocalTime/LocalDateTime/OffsetTime/OffsetDateTime/ZonedDateTime/Instant > types with optimization, just like int/long/float/double/String. > > # Optimized type and Specifier combinations > * java.util.Date > > %s > %tc (Sat Nov 04 12:02:33 EST 1999) > %tD DATE (mm/dd/yy) > %tF ISO_STANDARD_DATE (%Y-%m-%d) > %tT TIME (24 hour hh:mm:ss) > %tR TIME_24_HOUR hh:mm same as %H:%M > %tr TIME_12_HOUR (hh:mm:ss [AP]M) > > > * LocalDate > > %s > %tD DATE (mm/dd/yy) > %tF ISO_STANDARD_DATE (%Y-%m-%d) > > > * LocalDateTime > > %s > %tD DATE (mm/dd/yy) > %tF ISO_STANDARD_DATE (%Y-%m-%d) > %tT TIME (24 hour hh:mm:ss) > %tR TIME_24_HOUR hh:mm same as %H:%M > %tr TIME_12_HOUR (hh:mm:ss [AP]M) > > > * OffsetDateTime > > %s > %tD DATE (mm/dd/yy) > %tF ISO_STANDARD_DATE (%Y-%m-%d) > %tT TIME (24 hour hh:mm:ss) > %tR TIME_24_HOUR hh:mm same as %H:%M > %tr TIME_12_HOUR (hh:mm:ss [AP]M) > > > * ZonedDateTime > > %s > %tD DATE (mm/dd/yy) > %tF ISO_STANDARD_DATE (%Y-%m-%d) > %tT TIME (24 hour hh:mm:ss) > %tR TIME_24_HOUR hh:mm same as %H:%M > %tr TIME_12_HOUR (hh:mm:ss [AP]M) > > > * LocalTime > > %s > %tT TIME (24 hour hh:mm:ss) > %tR TIME_24_HOUR hh:mm same as %H:%M > %tr TIME_12_HOUR (hh:mm:ss [AP]M) > > > * OffsetTime > > %s > %tT TIME (24 hour hh:mm:ss) > %tR TIME_24_HOUR hh:mm same as %H:%M > %tr TIME_12_HOUR (hh:mm:ss [AP]M) > > > * Instant > > %s > > > # Performance Numbers > run on MacBook M1 Pro > > -Benchmark Mode Cnt Score Error Units > (baseline) > -StringTemplateFMT.dateFormat avgt 15 66.601 ? 0.863 ns/op > -StringTemplateFMT.instantFormat avgt 15 198.284 ? 5.804 ns/op > -StringTemplateFMT.ldtFormat avgt 15 103.625 ? 6.315 ns/op > -StringTemplateFMT.localTimeFormat avgt 15 44.750 ? 0.219 ns/op > -StringTemplateFMT.zdtFormat avgt 15 179.140 ? 8.379 ns/op > > +Benchmark Mode Cnt Score Error Units > (optimized) > +StringTemplateFMT.dateFormat avgt 15 29.425 ? 0.510 ns/op > (+126.35) > +StringTemplateFMT.instantFormat avgt 15 36.467 ? 0.114 ns/op > ... This pull request has been closed without being integrated. ------------- PR: https://git.openjdk.org/jdk/pull/16044