[threeten-dev] Ser performance
Xueming Shen
xueming.shen at oracle.com
Thu Mar 7 21:10:32 PST 2013
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