|
Java example source code file (AbstractMicrobenchmarkBase.java)
The AbstractMicrobenchmarkBase.java Java example source code/* * Copyright 2015 The Netty Project * * The Netty Project licenses this file to you under the Apache License, * version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ package io.netty.microbench.util; import static org.junit.Assert.assertNull; import io.netty.util.ResourceLeakDetector; import io.netty.util.internal.SystemPropertyUtil; import java.io.File; import java.util.ArrayList; import java.util.List; import org.junit.Test; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.results.format.ResultFormatType; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.ChainedOptionsBuilder; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Base class for all JMH benchmarks. */ @Warmup(iterations = AbstractMicrobenchmarkBase.DEFAULT_WARMUP_ITERATIONS) @Measurement(iterations = AbstractMicrobenchmarkBase.DEFAULT_MEASURE_ITERATIONS) @State(Scope.Thread) public abstract class AbstractMicrobenchmarkBase { protected static final int DEFAULT_WARMUP_ITERATIONS = 10; protected static final int DEFAULT_MEASURE_ITERATIONS = 10; protected static final String[] BASE_JVM_ARGS = { "-server", "-dsa", "-da", "-ea:io.netty...", "-XX:+AggressiveOpts", "-XX:+UseBiasedLocking", "-XX:+UseFastAccessorMethods", "-XX:+OptimizeStringConcat", "-XX:+HeapDumpOnOutOfMemoryError", "-Dio.netty.noResourceLeakDetection"}; static { ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED); } protected ChainedOptionsBuilder newOptionsBuilder() throws Exception { String className = getClass().getSimpleName(); ChainedOptionsBuilder runnerOptions = new OptionsBuilder() .include(".*" + className + ".*") .jvmArgs(jvmArgs()); if (getWarmupIterations() > 0) { runnerOptions.warmupIterations(getWarmupIterations()); } if (getMeasureIterations() > 0) { runnerOptions.measurementIterations(getMeasureIterations()); } if (getReportDir() != null) { String filePath = getReportDir() + className + ".json"; File file = new File(filePath); if (file.exists()) { file.delete(); } else { file.getParentFile().mkdirs(); file.createNewFile(); } runnerOptions.resultFormat(ResultFormatType.JSON); runnerOptions.result(filePath); } return runnerOptions; } protected abstract String[] jvmArgs(); protected static String[] removeAssertions(String[] jvmArgs) { List<String> customArgs = new ArrayList Other Java examples (source code examples)Here is a short list of links related to this Java AbstractMicrobenchmarkBase.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.