1

I am intrested how does exacly switch vs vavr's match performance seems, what is the easiest wy to check it?

@edit

I checked it, it seems like vavr's switch is like 2x slower than regular java switch

Shirabu
  • 99
  • 1
  • 4
  • Make measurements, put it in a for loop with 1k or 100k iterations. As probably you do not need to worry about performance if you are executing the statement only now and then. And post your findings here. I am also interested about results. – RenatoIvancic Apr 07 '20 at 18:04

1 Answers1

1

You can check the system time before and after your code block, for example:

    startTime = System.nanoTime();
    // your code goes here
    endTime = System.nanoTime()
Yan.F
  • 630
  • 5
  • 20
  • 3
    Note that proper benchmarks, especially micro-benchmarks require a lot more thought, especially regarding warm-up time, ensuring that the JIT has optimized the code as much as possible (unless you're measuring cold run time), ensuring suitable accuracy of the results, etc. There are libraries for that for a reason. – Joey Apr 07 '20 at 18:12
  • JMH is such a tool. See https://github.com/openjdk/jmh – Big Kahuna Jun 07 '22 at 07:51