What exactly is number of operations in JMH?

别说谁变了你拦得住时间么 提交于 2019-12-05 23:54:18

问题


The JavaDoc of annotation @OperationsPerInvocation in the Java Microbenchmarking Harness (JMH) states:

value public abstract int value

Returns: Number of operations per single Benchmark call. Default: 1

Being new to JMH I am wondering what type of operation (byte code operation, assembly code operation, Java operation etc) is meant here.

This question naturally refers to all places in JMH (documentation, output, comments etc) where the term 'operation' is used (e.g. "operation/time" unit or "time unit/operation").


回答1:


In JMH, "operation" is an abstract unit of work. See e.g. the sample result:

Benchmark               Mode  Cnt  Score   Error  Units
MyBenchmark.testMethod  avgt    5  5.068 ± 0.586  ns/op

Here, the performance is 5.068 nanoseconds per operation.

Nominally, one operation is one @Benchmark invocation. Some annotations, like @OperationsPerInvocation may tell that a single @Benchmark invocation means N operations. Similarly, batched runs, e.g. via @Measurement(batchSize = N) may say that one operation contains N @Benchmark invocations.



来源:https://stackoverflow.com/questions/32527223/what-exactly-is-number-of-operations-in-jmh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!