String.charAt vs StringBuilder.charAt performance

Raffaello Giulietti raffaello.giulietti at oracle.com
Tue Jul 22 14:10:59 UTC 2025


Hi,

the errors are so large that I'd dare to say that the measurements are 
unreliable.


On 2025-07-22 13:44, Brett Okken wrote:
> It does look like this is windows specific. If I run on WSL, I get 
> results similar to your linux-x64:
>
> Benchmark                       (data)  Mode  Cnt    Score     Error 
>  Units
> CharSequenceCharAtBenchmark.testString             ascii  avgt    3 
>  679.294 ± 302.947  ns/op
> CharSequenceCharAtBenchmark.testString         non-ascii  avgt    3 
>  702.071 ± 926.959  ns/op
> CharSequenceCharAtBenchmark.testStringBuilder      ascii  avgt    3 
>  682.815 ± 301.649  ns/op
> CharSequenceCharAtBenchmark.testStringBuilder  non-ascii  avgt    3 
>  678.169 ± 810.276  ns/op
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20250722/01857d0d/attachment.htm>


More information about the core-libs-dev mailing list