String indexOf Performance

Scott Palmer swpalmer at gmail.com
Fri Jan 27 20:18:16 UTC 2017


On Fri, Jan 27, 2017 at 1:43 PM, Reto Merz <reto.merz at abacus.ch> wrote:
> I have seen a big difference in 2014. Another dev has also confirmed this:
> https://sourceforge.net/p/findbugs/feature-requests/300/#cb7f
>
> In my case I have also used JITWatch to make sure that C2/HotSpot
> was really able to optimize/inline hot paths.
>
> Reto

Note the link above indicates the opposite of my observations.  They wrote:
       "After I change indexOf(".", int) to indexOf('.', int) the
total execution time decreased by 23%."

In my case indexOf('.', int) is quite a bit SLOWER.  I brought it up
here because it was so counter-intuitive.

Regards,

Scott


>
>
>
> On 27.01.2017 19:37, Aleksey Shipilev wrote:
>>
>> On 01/27/2017 07:22 PM, Scott Palmer wrote:
>>>
>>> I looped through those 100,000 times.  I should do a proper JMH
>>> benchmark, but
>>> for now here's a link to the code:
>>>
>>>    http://pastebin.com/dWcf7rQJ
>>
>> Ah, OK. There's no reason to dive into the performance of this particular
>> benchmark. Please isolate the behavior you are seeing with JMH, and
>> possibly see
>> the generated code with -prof perfasm (or xperfasm, since you're on
>> Windows).
>>
>> Thanks,
>> -Aleksey
>>
>


More information about the jdk9-dev mailing list