RFR: 8058230: Improve java.sql toString formatting
Ulf Zibis
Ulf.Zibis at CoSoCo.de
Thu Sep 11 15:39:41 UTC 2014
Maybe consider https://bugs.openjdk.java.net/browse/JDK-6914113
Especially note the last comment there.
-Ulf
Am 11.09.2014 um 16:44 schrieb Claes Redestad:
> Hi,
>
> requesting reviews for this patch which optimizes java.sql.Date/Time/Timestamp::toString
> by avoiding some unnecessary object allocations. java.sql.Date had similar optimizations
> applied which this patch improves upon.
>
> bug: https://bugs.openjdk.java.net/browse/JDK-8058230
> webrev: http://cr.openjdk.java.net/~redestad/8058230/webrev.00/
>
> Testing: jtreg jdk/test/java/sql with and without 8057826 tests
>
> Before/after performance running a minimal JMH micro[1]:
>
> Benchmark Mode Samples Score Score error Units
> t.DateBench.dateToString thrpt 20 30225.628 623.887 ops/ms
> t.DateBench.dateToString thrpt 20 38350.173 1349.432 ops/ms # 1.3x
>
> t.DateBench.timeToString thrpt 20 11793.338 232.121 ops/ms
> t.DateBench.timeToString thrpt 20 47048.344 1969.939 ops/ms # 4.0x
>
> t.DateBench.timestampToString thrpt 20 2529.601 45.990 ops/ms
> t.DateBench.timestampToString thrpt 20 14143.612 407.351 ops/ms # 5.6x
>
> /Claes
>
> [1]
>
> package test;
>
> import org.openjdk.jmh.annotations.*;
>
> @State(Scope.Thread)
> public class DateBench {
>
> public java.sql.Time time = java.sql.Time.valueOf("15:15:25");
>
> @Benchmark
> public String timeToString() {
> return time.toString();
> }
>
> public java.sql.Date date = java.sql.Date.valueOf("2013-01-01");
>
> @Benchmark
> public String dateToString() {
> return date.toString();
> }
>
> public Timestamp timestamp = Timestamp.valueOf("1999-12-13 15:15:25.645634");
>
> @Benchmark
> public String timestampToString() {
> return timestamp.toString();
> }
>
> }
>
More information about the core-libs-dev
mailing list