[threeten-dev] Ser performance

Xueming Shen xueming.shen at oracle.com
Fri Mar 8 08:27:34 PST 2013


On 3/8/13 2:02 AM, Stephen Colebourne wrote:
> On 8 March 2013 05:10, Xueming Shen <xueming.shen at oracle.com> wrote:
>> 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/
> I'm happy with the principle of the change. I think it might be
> cleaner to read and faster if you checked the first character, then
> checked the remaining characters. This is safe as the string is at
> least length 2.

The assumption of current impl is that in "normal" scenario the tested
zoneId name is valid and  most of the character is A-Z and a-z. Maybe
we should move _ and / up before 0-9. But I would guess the suggested
approach would not be faster.

>
> You should also delete the pattern rather than just commenting it out.
>
> I'd also prefer the checkName() method to be located after ofId(), not
> before, in the source file.
>
> thanks
> Stephen



More information about the threeten-dev mailing list