JMH @Fork(warmup) vs @Warmup

@Fork의 warmup 어트리뷰트와 @Warmup 어노테이션의 차이를 StackOverflow에 정리가 잘된 답변이 있어 가져와 봤다.


With a JMH benchmark you run one or more forks sequentially, and one or more iterations of your benchmark code within each fork. There are two forms of warmup associated with this:

  • At the fork level the warmups parameter to @Fork specifies how many warmup forks to run before running the benchmarked forks. Warmup forks are ignored when creating the benchmark results.
  • The @Warmup annotation lets you specify warmup characteristics within a fork, including how many warmup iterations to run. Warmup iterations are ignored when creating the benchmark results.

For example:

  • @Fork(value = 3, warmups = 2) means that 5 forks will be run sequentially. The first two will be warmup runs which will be ignored, and the final 3 will be used for benchmarking.
  • @Warmup(iterations = 5, time = 55, timeUnit = TimeUnit.MILLISECONDS) means that there will be 5 warmup iterations within each fork. The timings from these runs will be ignored when producing the benchmark results.
  • @Measurement(iterations = 4, time = 44, timeUnit = TimeUnit.MILLISECONDS) means that your benchmark iterations will be run 4 times (after the 5 warmup iterations).

So the overall impact of the warmup settings shown above is that:

  • Only the final three of the five forks will be used for the benchmark results.
  • Only the final four iterations within each non-warmup fork will be used for the benchmark results.

That is why the JMH output below (which was run using those annotations against the benchmarked method) shows Cnt 12 at the end of the run: 3 forks x 4 iterations = 12.

jmharmup 


출처: https://stackoverflow.com/a/48363614/1411827


댓글

이 블로그의 인기 게시물

[Protocol] WIEGAND 통신

Orange for Oracle에서 한글 깨짐 해결책

[UI] GNB·LNB·SNB·FNB 용어 설명