[threeten-dev] Ser performance
roger riggs
roger.riggs at oracle.com
Fri Mar 8 07:25:44 PST 2013
Hi Sherman,
I would also be interested in the comparison with the serialization of
java.util.Date
though it is likely to be similar to LocalDate since it just serializes
a long.
Does Regex have an patterns for which it has optimized implementations?
It should be possible to normalize the patterns and with some data gathering
code up some specific implementations.
Regex has always seemed like overkill to me for most patterns.
The code for checkname could be optimized a bit as Stephen suggested
and could also put the individual comparisons in numeric order and
if the character was > making a quick continue.
Either way its a good improvement.
Thanks, Roger
On 3/8/2013 12:10 AM, Xueming Shen wrote:
> I was asked to compare the ZDT and GregorianCalendar the other day, here
> are the data.
>
> --------LocalDate--------
> serSize=16
> Writing: 6655
> Reading: 3318
> --------LocalTime--------
> serSize=17
> Writing: 6335
> Reading: 2968
> --------LocalDateTime--------
> serSize=23
> Writing: 6317
> Reading: 3392
> --------ZonedDateTime--------
> serSize=46
> Writing: 7731
> Reading: 15841
> --------GregorianCal--------
> serSize=266
> Writing: 28491
> Reading: 43594
> --------ZoneId.of()--------
> Reading: 4500
>
> Obviously JSR310 ZDT is much faster than GregorianCalendar, both
> serialization and de-ser. with a much smaller size, as expected.
>
> However I noticed that the ZDT reading/de-serialization time is kinda
> "unproportional"
> bigger, given it only has a LDT, a ZoneOffset and ZoneId to read in.
> It appears we "spend"
> most of the ZoneRegion.ofId() time on the name validation via the
> regex. the regex's
> matches() is too slow for this "simple" validation, unfortunately.
> Though I hate to propose,
> as the proud maintainer of jdk regex:-), but I think it might worth
> considering the simple
> char by char direct match, as we did in java.nio.Charset for the
> similar name validation
> situation, as showed in the following webrev.
>
> http://cr.openjdk.java.net/~sherman/jdk8_threeten/zidPerm/
>
> It boost the ZoneId.of() speed from 4500 to 1261, and cut the ZDT
> de-serialization
> time almost in half.
> (test case:
> http://cr.openjdk.java.net/~sherman/jdk8_threeten/zidPerm/SerTest.java)
>
> --------LocalDate--------
> serSize=16
> Writing: 6741
> Reading: 3328
> --------LocalTime--------
> serSize=17
> Writing: 6237
> Reading: 3000
> --------LocalDateTime--------
> serSize=23
> Writing: 6290
> Reading: 3412
> --------ZonedDateTime--------
> serSize=46
> Writing: 7566
> Reading: 8054
> --------GregorianCal--------
> serSize=266
> Writing: 29517
> Reading: 42369
> --------ZoneId.of()--------
> Reading: 1261
>
> -Sherman
>
More information about the threeten-dev
mailing list