Vector API performance

Kasper Nielsen kasperni at gmail.com
Fri May 26 06:04:52 UTC 2023


Hi,

You cannot reliable benchmark code on the JVM as you do in your example.
As you are also measuring things such as VM startup, code compilation,
and lots of other things in addition to your own code.

Instead, you should rewrite your benchmarks using JMH.
https://github.com/openjdk/jmh
Which is the defacto micro benchmarking tool for the JVM.
You can find loads of articles and videos about the tool if you search.

Best,
  Kasper



On Fri, 26 May 2023 at 04:24, Bruno Rafael Sant Ana
<bruno.santana.ti at gmail.com> wrote:
>
> Hi everyone,
>
> This is the first time I'm using a Java mailing list, so hopefully I'm doing it correctly.
>
> I've heard that the Vector API should increase the performance when the computer has a SIMD architecture.
>
> I wrote this code to test the Vector API and surprisingly it seems to be slower than the traditional way:
>
> https://github.com/brunosantanati/java-new-features/blob/main/src/main/java/me/bruno/santana/incubator/VectorApiDemo.java
>
> I got 5969 ns (traditional way) VS 48475736 ns (Vector API code). Why is that? Maybe my laptop has no SIMD capabilities?
>
> In addition to that, I have one more question. When I'm using the IntVector.fromArray method passing an array with length less than 16 I get an IndexOutOfBoundsException. Why is that?
>
> Thank you!
>
> --
>
> "Any fool can write code that a computer can understand. Good programmers write code that humans can understand." Martin Fowler


More information about the panama-dev mailing list