RFR: 8058230: Improve java.sql toString formatting
Lance Andersen
lance.andersen at oracle.com
Thu Sep 11 15:32:40 UTC 2014
Hi Claes,
I think this is OK, however, would like to see if others feel if formatDecimalInt should be located elsewhere so that we just make this change once.
Best,
Lance
On Sep 11, 2014, at 10:44 AM, Claes Redestad <claes.redestad at oracle.com> wrote:
> 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();
> }
>
> }
Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037
Oracle Java Engineering
1 Network Drive
Burlington, MA 01803
Lance.Andersen at oracle.com
More information about the core-libs-dev
mailing list