本文介绍了JMH中的确切操作次数是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java Microbenchmarking Harness(JMH)中的注释@OperationsPerInvocation的JavaDoc状态如下:

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

Returns:每个基准测试调用的操作数.默认值:1

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

对JMH来说是新手,我想知道这里是什么类型的操作(字节码操作,汇编代码操作,Java操作等).

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

这个问题自然是指JMH中使用操作"一词的所有位置(例如"操作/时间"单位或"") ;时间单位/操作").

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").

推荐答案

在JMH中,操作"是一个抽象的工作单元.参见例如样本结果:

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

此处,每次操作的性能为5.068纳秒.

Here, the performance is 5.068 nanoseconds per operation.

名义上,一个操作就是一个@Benchmark调用.某些注释,例如@OperationsPerInvocation可能告诉您,单个@Benchmark调用意味着N次操作.同样,批量运行,例如通过@Measurement(batchSize = N)可以说一个操作包含N个@Benchmark调用.

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.

这篇关于JMH中的确切操作次数是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 07:26