Performance of Pattern Matching for switch (Third Preview)

Brian Goetz brian.goetz at oracle.com
Wed Aug 10 18:12:11 UTC 2022


Yes, the current translation is deliberately unoptimized, and in fact, 
the most recent version has some translation issues that make it 
accidentally worse as well (such as some unnecessary boxing.) These are 
currently being worked on.

On 8/10/2022 6:04 AM, Jordan Zimmerman wrote:
> Hi Folks,
>
> I've been experimenting with Pattern Matching for switch (Third 
> Preview). I noticed that the performance of these enhanced switches is 
> far worse than manual matching. Is this due to this only being a 
> preview and optimizations have yet to be done? Anyway, I thought I'd 
> mention what I found as an FYI.
>
> Here's the jmh benchmark I used:
> https://gist.github.com/Randgalt/a68ceee62cd8127431cbe6e7afbfdf44
>
> Here are the results:
>
> Benchmark                         Mode  Cnt      Score       Error  Units
> TestEnhancedSwitch.testEnhancedSwitch  thrpt    5  30789.482 ± 
> 17667.365  ops/s
> TestEnhancedSwitch.testManualSwitch    thrpt    5  44651.612 ± 
>  5135.641  ops/s
>
> Cheers.
>
> -Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20220810/d1df32f2/attachment.htm>


More information about the amber-dev mailing list