RFR: 8353013: java.net.URI.create(String) may have low performance to scan the host/domain name from URI string when the hostname starts with number [v2]
Rohitash
duke at openjdk.org
Mon Apr 14 16:37:43 UTC 2025
On Sat, 12 Apr 2025 06:06:58 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Rohitash has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Add benchmark
>> - Address PR comments
>
> test/jdk/java/net/URI/Test.java line 1791:
>
>> 1789:
>> 1790: // 8353013 - java.net.URI.create(String) may have low performance to scan the host/domain name from
>> 1791: // URI string when the hostname starts with number
>
> This comment looks a bit out of place in a unit test. I think start with a JMH benchmark and change the comment in the unit test to make it clearer that it's providing more test coverage for cases where the authority component of a hierarchical URI has a host component that starts with a number.
Thanks! I have updated the comment and added a JMH benchmark.
## Before
Benchmark Mode Cnt Score Error Units
URIAuthorityParsingBenchmark.createUriWithNumericHostPrefix avgt 15 1555.875 ± 66.857 ns/op
URIAuthorityParsingBenchmark.createUriWithStandardHost avgt 15 268.101 ± 1.634 ns/op
## After
Benchmark Mode Cnt Score Error Units
URIAuthorityParsingBenchmark.createUriWithNumericHostPrefix avgt 15 381.902 ± 4.821 ns/op
URIAuthorityParsingBenchmark.createUriWithStandardHost avgt 15 271.377 ± 10.165 ns/op
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24295#discussion_r2042505911
More information about the net-dev
mailing list