在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):melix/jmh-gradle-plugin开源软件地址(OpenSource Url):https://github.com/melix/jmh-gradle-plugin开源编程语言(OpenSource Language):Groovy 46.2%开源软件介绍(OpenSource Introduction):JMH Gradle PluginThis plugin integrates the JMH micro-benchmarking framework with Gradle. Usagebuild.gradle
plugins {
id "me.champeau.jmh" version "0.6.6"
}
Samples can be found in the samples folder. What plugin version to use?Version 0.6+ requires Gradle 6.8+.
ConfigurationThe plugin makes it easy to integrate into an existing project thanks to a specific configuration. In particular,
benchmark source files are expected to be found in the src/jmh |- java : java sources for benchmarks |- resources : resources for benchmarks The plugin creates a build.gradle
dependencies {
jmh 'commons-io:commons-io:2.4'
} The plugin uses JMH 1.29. You can upgrade the version just by changing the version in the build.gradle
dependencies {
jmh 'org.openjdk.jmh:jmh-core:0.9'
jmh 'org.openjdk.jmh:jmh-generator-annprocess:0.9'
} TasksThe project will add several tasks:
The gradle jmh Configuration optionsBy default, all benchmarks will be executed, and the results will be generated into build.gradle
jmh {
includes = ['some regular expression'] // include pattern (regular expression) for benchmarks to be executed
excludes = ['some regular expression'] // exclude pattern (regular expression) for benchmarks to be executed
iterations = 10 // Number of measurement iterations to do.
benchmarkMode = ['thrpt','ss'] // Benchmark mode. Available modes are: [Throughput/thrpt, AverageTime/avgt, SampleTime/sample, SingleShotTime/ss, All/all]
batchSize = 1 // Batch size: number of benchmark method calls per operation. (some benchmark modes can ignore this setting)
fork = 2 // How many times to forks a single benchmark. Use 0 to disable forking altogether
failOnError = false // Should JMH fail immediately if any benchmark had experienced the unrecoverable error?
forceGC = false // Should JMH force GC between iterations?
jvm = 'myjvm' // Custom JVM to use when forking.
jvmArgs = ['Custom JVM args to use when forking.']
jvmArgsAppend = ['Custom JVM args to use when forking (append these)']
jvmArgsPrepend =[ 'Custom JVM args to use when forking (prepend these)']
humanOutputFile = project.file("${project.buildDir}/results/jmh/human.txt") // human-readable output file
resultsFile = project.file("${project.buildDir}/results/jmh/results.txt") // results file
operationsPerInvocation = 10 // Operations per invocation.
benchmarkParameters = [:] // Benchmark parameters.
profilers = [] // Use profilers to collect additional data. Supported profilers: [cl, comp, gc, stack, perf, perfnorm, perfasm, xperf, xperfasm, hs_cl, hs_comp, hs_gc, hs_rt, hs_thr, async]
timeOnIteration = '1s' // Time to spend at each measurement iteration.
resultFormat = 'CSV' // Result format type (one of CSV, JSON, NONE, SCSV, TEXT)
synchronizeIterations = false // Synchronize iterations?
threads = 4 // Number of worker threads to run with.
threadGroups = [2,3,4] //Override thread group distribution for asymmetric benchmarks.
timeout = '1s' // Timeout for benchmark iteration.
timeUnit = 'ms' // Output time unit. Available time units are: [m, s, ms, us, ns].
verbosity = 'NORMAL' // Verbosity mode. Available modes are: [SILENT, NORMAL, EXTRA]
warmup = '1s' // Time to spend at each warmup iteration.
warmupBatchSize = 10 // Warmup batch size: number of benchmark method calls per operation.
warmupForks = 0 // How many warmup forks to make for a single benchmark. 0 to disable warmup forks.
warmupIterations = 1 // Number of warmup iterations to do.
warmupMode = 'INDI' // Warmup mode for warming up selected benchmarks. Warmup modes are: [INDI, BULK, BULK_INDI].
warmupBenchmarks = ['.*Warmup'] // Warmup benchmarks to include in the run in addition to already selected. JMH will not measure these benchmarks, but only use them for the warmup.
zip64 = true // Use ZIP64 format for bigger archives
jmhVersion = '1.29' // Specifies JMH version
includeTests = true // Allows to include test sources into generate JMH jar, i.e. use it when benchmarks depend on the test classes.
duplicateClassesStrategy = DuplicatesStrategy.FAIL // Strategy to apply when encountring duplicate classes during creation of the fat jar (i.e. while executing jmhJar task)
} JMH Options MappingThe following table describes the mappings between JMH’s command line options and the plugin’s extension properties.
Dependency on project filesThe It is possible a dependency on the Using JMH Gradle Plugin with Shadow PluginOptionally it is possible to use Shadow Plugin to do actual JMH jar
creation. The configuration of Shadow Plugin for JMH jar is done via build.gradle
jmhJar {
append('META-INF/spring.handlers')
append('META-INF/spring.schemas')
exclude 'LICENSE'
} Duplicate dependencies and classesThis plugin will merge all dependencies that are defined as part of In addition plugin applies DuplicatesStrategy
defined via It is possible to change this behavior by configuring build.gradle
jmh {
duplicateClassesStrategy = DuplicatesStrategy.WARN
} However if you do encounter problem with defaut value it means that the classpath or sources in your project do contain duplicate classes which means that it is not possible to predict which one will be used when fat jar will generated. To deal with duplicate files other than classes use Shadow Plugin capabilities, see Using JMH Gradle Plugin with Shadow Plugin. Known issuesIf a benchmark is written in Groovy, you must use the same version of Groovy as the one bundled with Gradle. This is a limitation of the Gradle Worker API that is going to be fixed in the future. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论