55 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Groovy
		
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Groovy
		
	
	
	
plugins {
 | 
						|
  id "me.champeau.gradle.jmh" version "0.5.0"
 | 
						|
}
 | 
						|
 | 
						|
apply from: "$rootDir/gradle/java.gradle"
 | 
						|
 | 
						|
dependencies {
 | 
						|
  jmh deps.opentelemetryApi
 | 
						|
  jmh deps.bytebuddyagent
 | 
						|
 | 
						|
  jmh 'javax.servlet:javax.servlet-api:4.0.1'
 | 
						|
  jmh 'com.google.http-client:google-http-client:1.19.0'
 | 
						|
  jmh 'org.eclipse.jetty:jetty-server:9.4.1.v20170120'
 | 
						|
  jmh 'org.eclipse.jetty:jetty-servlet:9.4.1.v20170120'
 | 
						|
}
 | 
						|
 | 
						|
jmh {
 | 
						|
  timeUnit = 'ms' // Output time unit. Available time units are: [m, s, ms, us, ns].
 | 
						|
  benchmarkMode = ['avgt']
 | 
						|
  timeOnIteration = '20s'
 | 
						|
  iterations = 1 // Number of measurement iterations to do.
 | 
						|
  fork = 1 // How many times to forks a single benchmark. Use 0 to disable forking altogether
 | 
						|
//  jvmArgs += ["-XX:+UnlockDiagnosticVMOptions", "-XX:+DebugNonSafepoints", "-XX:StartFlightRecording=delay=5s,dumponexit=true,name=jmh-benchmark,filename=$rootDir/benchmark/build/reports/jmh/jmh-benchmark.jfr"]
 | 
						|
//  jvmArgs += ["-agentpath:$rootDir/benchmark/src/jmh/resources/libasyncProfiler.so=start,collapsed,file=$rootDir/benchmark/build/reports/jmh/profiler.txt"]
 | 
						|
  failOnError = true // Should JMH fail immediately if any benchmark had experienced the unrecoverable error?
 | 
						|
  warmup = '5s' // 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.
 | 
						|
 | 
						|
//  profilers = ['stack:lines=5;detailLine=true;period=5;excludePackages=true']
 | 
						|
  // 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]
 | 
						|
  profilers = ['io.opentelemetry.benchmark.UsedMemoryProfiler', 'gc']
 | 
						|
 | 
						|
//  humanOutputFile = project.file("${project.buildDir}/reports/jmh/human.txt") // human-readable output file
 | 
						|
//  operationsPerInvocation = 10 // Operations per invocation.
 | 
						|
//  synchronizeIterations = false // Synchronize iterations?
 | 
						|
  timeout = '5s' // Timeout for benchmark iteration.
 | 
						|
//  includeTests = false
 | 
						|
  // Allows to include test sources into generate JMH jar, i.e. use it when benchmarks depend on the test classes.
 | 
						|
 | 
						|
  duplicateClassesStrategy = DuplicatesStrategy.EXCLUDE
 | 
						|
  jmhVersion = '1.23' // Specifies JMH version
 | 
						|
}
 | 
						|
 | 
						|
tasks.jmh.dependsOn(':opentelemetry-javaagent:shadowJar')
 | 
						|
 | 
						|
/*
 | 
						|
If using libasyncProfiler, use the following to generate nice svg flamegraphs.
 | 
						|
sed '/unknown/d' benchmark/build/reports/jmh/profiler.txt | sed '/^thread_start/d' | sed '/not_walkable/d' > benchmark/build/reports/jmh/profiler-cleaned.txt
 | 
						|
(using https://github.com/brendangregg/FlameGraph)
 | 
						|
./flamegraph.pl --color=java benchmark/build/reports/jmh/profiler-cleaned.txt > benchmark/build/reports/jmh/jmh-master.svg
 | 
						|
 */
 | 
						|
 |