Java 类org.openjdk.jmh.annotations.TearDown 实例源码
项目:jmh
文件:StateObjectHandler.java
private void checkHelpers(MethodInfo mi, Class<? extends Annotation> annClass) {
// OK to have these annotation for @State objects
if (BenchmarkGeneratorUtils.getAnnSuper(mi.getDeclaringClass(), State.class) == null) {
if (!mi.getDeclaringClass().isAbstract()) {
throw new GenerationException(
"@" + TearDown.class.getSimpleName() + " annotation is placed within " +
"the class not having @" + State.class.getSimpleName() + " annotation. " +
"This has no behavioral effect, and prohibited.",
mi);
}
}
if (!mi.isPublic()) {
throw new GenerationException(
"@" + annClass.getSimpleName() + " method should be public.",
mi);
}
if (!mi.getReturnType().equalsIgnoreCase("void")) {
throw new GenerationException(
"@" + annClass.getSimpleName() + " method should not return anything.",
mi);
}
}
项目:jmh
文件:BenchmarkStateHelperTimesTest.java
@TearDown(Level.Trial)
public void tearDownLATEST() { // this name ensures this is the latest teardown to run
Assert.assertEquals("Setup1 called once", 1, countSetupRun1.get());
Assert.assertEquals("Setup2 called once", 1, countSetupRun2.get());
Assert.assertEquals("Setup3 called twice", 2, countSetupIteration1.get());
Assert.assertEquals("Setup4 called twice", 2, countSetupIteration2.get());
// These asserts make no sense for Benchmark tests
// Assert.assertEquals("Setup5 = invocation count", countInvocations.get(), countSetupInvocation1.get());
// Assert.assertEquals("Setup6 = invocation count", countInvocations.get(), countSetupInvocation2.get());
Assert.assertEquals("TearDown1 called once", 1, countTearDownRun1.get());
Assert.assertEquals("TearDown2 called once", 1, countTearDownRun2.get());
Assert.assertEquals("TearDown3 called twice", 2, countTearDownIteration1.get());
Assert.assertEquals("TearDown4 called twice", 2, countTearDownIteration2.get());
// These two asserts make no sense for Benchmark tests.
// Assert.assertEquals("TearDown5 = invocation count", countInvocations.get(), countTearDownInvocation1.get());
// Assert.assertEquals("TearDown6 = invocation count", countInvocations.get(), countTearDownInvocation2.get());
}
项目:jmh
文件:BenchmarkBenchHelperTimesTest.java
@TearDown(Level.Trial)
public void tearDownLATEST() { // this name ensures this is the latest teardown to run
Assert.assertEquals("Setup1 called once", 1, countSetupRun1.get());
Assert.assertEquals("Setup2 called once", 1, countSetupRun2.get());
Assert.assertEquals("Setup3 called twice", 2, countSetupIteration1.get());
Assert.assertEquals("Setup4 called twice", 2, countSetupIteration2.get());
// These asserts make no sense for Benchmark tests
// Assert.assertEquals("Setup5 = invocation count", countInvocations.get(), countSetupInvocation1.get());
// Assert.assertEquals("Setup6 = invocation count", countInvocations.get(), countSetupInvocation2.get());
Assert.assertEquals("TearDown1 called once", 1, countTearDownRun1.get());
Assert.assertEquals("TearDown2 called once", 1, countTearDownRun2.get());
Assert.assertEquals("TearDown3 called twice", 2, countTearDownIteration1.get());
Assert.assertEquals("TearDown4 called twice", 2, countTearDownIteration2.get());
// These two asserts make no sense for Benchmark tests.
// Assert.assertEquals("TearDown5 = invocation count", countInvocations.get(), countTearDownInvocation1.get());
// Assert.assertEquals("TearDown6 = invocation count", countInvocations.get(), countTearDownInvocation2.get());
}
项目:openjdk-jdk10
文件:NodesState.java
@TearDown(Level.Invocation)
public void afterInvocation() {
if (invocation == 0) {
// Only need to check the first invocation
invocation++;
for (int i = 0; i < nodes.length; i++) {
if (nodes[i] != originalNodes[i]) {
throw new InternalError(String.format("Benchmark method mutated node %d: original=%s, current=%s", i, originalNodes[i], nodes[i]));
}
}
}
}
项目:PACE
文件:BenchmarkBase.java
/**
* Ensures Accumulo and test are cleaned up.
*/
@TearDown(Level.Trial)
public void teardownTrial() throws Exception {
for (String table : tables) {
AccumuloInstance.deleteTable(table);
}
AccumuloInstance.teardown();
}
项目:Mastering-Mesos
文件:UpdateStoreBenchmarks.java
@TearDown(Level.Iteration)
public void tearDownIteration() {
storage.write((NoResult.Quiet) storeProvider -> {
storeProvider.getJobUpdateStore().deleteAllUpdatesAndEvents();
storeProvider.getLockStore().deleteLocks();
});
}
项目:Mastering-Mesos
文件:UpdateStoreBenchmarks.java
@TearDown(Level.Iteration)
public void tearDownIteration() {
storage.write((NoResult.Quiet) storeProvider -> {
storeProvider.getJobUpdateStore().deleteAllUpdatesAndEvents();
storeProvider.getLockStore().deleteLocks();
});
}
项目:graal-core
文件:NodesState.java
@TearDown(Level.Invocation)
public void afterInvocation() {
if (invocation == 0) {
// Only need to check the first invocation
invocation++;
for (int i = 0; i < nodes.length; i++) {
if (nodes[i] != originalNodes[i]) {
throw new InternalError(String.format("Benchmark method mutated node %d: original=%s, current=%s", i, originalNodes[i], nodes[i]));
}
}
}
}
项目:graylog-plugin-pipeline-processor
文件:PipelinePerformanceBenchmarks.java
@TearDown
public void dumpMetrics() throws Exception {
// enable when using yourkit for single runs
// if (controller != null) {
// controller.captureSnapshot(Controller.SNAPSHOT_WITH_HEAP);
// }
final MetricRegistry metrics = injector.getInstance(MetricRegistry.class);
// make the registry available to the profiler
metricRegistry = metrics;
final ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics)
.outputTo(new PrintStream("/tmp/bench-" + directoryName + ".txt"))
.build();
reporter.report();
}
项目:indexr
文件:BHCompressBenchmark.java
@TearDown(Level.Trial)
public void tearDown() {
byteData.free();
byteCmpData.free();
shortData.free();
shortCmpData.free();
intData.free();
intCmpData.free();
longData.free();
longCmpData.free();
}
项目:indexr
文件:SegmentBenchmark.java
@TearDown(Level.Trial)
public void cleanup() throws IOException {
indexMemCache.close();
packMemCache.close();
System.gc();
FileUtils.deleteDirectory(workDir.toFile());
}
项目:silverflash
文件:TlsTcpTransportBenchmark.java
@TearDown
public void detroyTestEnvironment() throws IOException, InterruptedException {
clientTransport.close();
tcpAcceptor.close();
serverIOReactor.close();
clientIOReactor.close();
}
项目:silverflash
文件:UdpTransportBenchmark.java
@TearDown
public void detroyTestEnvironment() throws Exception {
clientTransport.close();
serverTransport.close();
if (serverIOReactor != null) {
serverIOReactor.close();
}
if (clientIOReactor != null) {
clientIOReactor.close();
}
}
项目:silverflash
文件:TcpTransportBenchmark.java
@TearDown
public void detroyTestEnvironment() throws IOException, InterruptedException {
clientTransport.close();
tcpAcceptor.close();
serverIOReactor.close();
if (clientIOReactor != null) {
clientIOReactor.close();
}
}
项目:lin-check
文件:QueueRoundTripLatency.java
/**
* We want to always start with an empty inbound. Iteration tear downs are synchronized.
*/
@TearDown(Level.Iteration)
public void clear() {
// SPSC -> consumer must clear the queue
in.clear();
ping = in;
pong = out;
}
项目:lin-check
文件:QueueRoundTripLatency.java
/**
* We want to always start with an empty inbound. Iteration tear downs are synchronized.
*/
@TearDown(Level.Iteration)
public void clear() {
// SPSC -> consumer must clear the queue
end.clear();
ping = start;
pong = end;
}
项目:lin-check
文件:QueueThroughputBusy.java
@TearDown(Level.Iteration)
public void emptyQ() {
if (marker.get() == null)
return;
// sadly the iteration tear down is performed from each participating thread, so we need to guess
// which is which (can't have concurrent access to poll).
while (q.poll() != null)
;
}
项目:lin-check
文件:QueueThroughputYield.java
@TearDown(Level.Iteration)
public void emptyQ() {
if (marker.get() == null)
return;
// sadly the iteration tear down is performed from each participating thread, so we need to guess
// which is which (can't have concurrent access to poll).
while (q.poll() != null)
;
}
项目:stringbench
文件:SinglePatternMatcherBenchmark.java
@TearDown(Level.Iteration)
public void validate() {
for (String pattern : sample.getPattern()) {
List<Integer> result = results.get(pattern);
sample.validate(pattern, result);
}
}
项目:Java-Algorithms
文件:MultiThread.java
@TearDown(Level.Invocation)
public void tearDown()
throws Exception {
resolver.shutDownResolver();
assert results != null && results.size() == largeRound.numberOfTasks()
: "Results should have size " + largeRound.numberOfTasks() + " but has " + results;
}
项目:Java-Algorithms
文件:SingleThread.java
@TearDown(Level.Invocation)
public void tearDown()
throws Exception {
resolver.shutDownResolver();
assert results != null && results.size() == largeRound.numberOfTasks()
: "Results should have size " + largeRound.numberOfTasks() + " but has " + results;
}
项目:ignite
文件:BPlusTreeBenchmark.java
/**
* @throws Exception If failed.
*/
@TearDown
public void tearDown() throws Exception {
tree.destroy();
pageMem.stop();
}
项目:tchannel-java
文件:PingPongMultiServerBenchmark.java
@TearDown(Level.Trial)
public void teardown() throws Exception {
this.client.shutdown(false);
for (TChannel server : servers) {
server.shutdown(false);
}
}
项目:jmh
文件:GroupBenchSetupOrderTest.java
@TearDown(Level.Trial)
public void tearDown() {
Assert.assertTrue("Trial(D) < Trial(1)", runD < run1);
Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2);
Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3);
Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1);
Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2);
Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3);
Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1);
Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2);
Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3);
}
项目:jmh
文件:BenchmarkStateSameThreadTest.java
@TearDown(Level.Trial)
public void teardownZZZ() { // should perform last
Assert.assertFalse("Test sanity", testInvocationThread.isEmpty());
Assert.assertTrue("test <: setupRun", testInvocationThread.containsAll(setupRunThread));
Assert.assertTrue("test <: setupIteration", testInvocationThread.containsAll(setupIterationThread));
Assert.assertTrue("test <: setupInvocation", testInvocationThread.containsAll(setupInvocationThread));
Assert.assertTrue("test <: teardownRun", testInvocationThread.containsAll(teardownRunThread));
Assert.assertTrue("test <: teardownIteration", testInvocationThread.containsAll(teardownIterationThread));
Assert.assertTrue("test <: teardownInvocation", testInvocationThread.containsAll(teardownInvocationThread));
}
项目:jmh
文件:ThreadStateSetupOrderTest.java
@TearDown(Level.Trial)
public void tearDown() {
Assert.assertTrue("Trial(D) < Trial(1)", runD < run1);
Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2);
Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3);
Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1);
Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2);
Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3);
Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1);
Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2);
Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3);
}
项目:grpc-java
文件:StreamingPingPongsPerSecondBenchmark.java
/**
* Stop the running calls then stop the server and client channels.
*/
@Override
@TearDown(Level.Trial)
public void teardown() throws Exception {
completed.set(true);
if (!latch.await(5, TimeUnit.SECONDS)) {
logger.warning("Failed to shutdown all calls.");
}
super.teardown();
}
项目:jmh
文件:ThreadBenchSameThreadTest.java
@TearDown(Level.Trial)
public void tearDownRun() {
if (teardownRunThread == null) {
teardownRunThread = Thread.currentThread();
}
Assert.assertEquals("teardownRun", teardownRunThread, Thread.currentThread());
}
项目:jmh
文件:SingleShotBatchAnn05Test.java
@TearDown(Level.Iteration)
public void tearDownIter() {
if(isWarmup()) {
Assert.assertEquals(WARMUP_BATCH + " batch size expected", WARMUP_BATCH, batchCount.get());
} else {
Assert.assertEquals(MEASUREMENT_BATCH + " batch size expected", MEASUREMENT_BATCH, batchCount.get());
}
}
项目:jmh
文件:SingleShotBatchApi05Test.java
@TearDown(Level.Iteration)
public void tearDownIter() {
if(isWarmup()) {
Assert.assertEquals(WARMUP_BATCH + " batch size expected", WARMUP_BATCH, batchCount.get());
} else {
Assert.assertEquals(MEASUREMENT_BATCH + " batch size expected", MEASUREMENT_BATCH, batchCount.get());
}
}
项目:grpc-java
文件:UnaryCallResponseBandwidthBenchmark.java
/**
* Stop the running calls then stop the server and client channels.
*/
@Override
@TearDown(Level.Trial)
public void teardown() throws Exception {
completed.set(true);
Thread.sleep(5000);
super.teardown();
}
项目:jmh
文件:ThreadBenchSetupOrderTest.java
@TearDown(Level.Trial)
public void tearDown() {
Assert.assertTrue("Trial(D) < Trial(1)", runD < run1);
Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2);
Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3);
Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1);
Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2);
Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3);
Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1);
Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2);
Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3);
}
项目:jmh
文件:GroupStateOrderTest.java
@TearDown(Level.Trial)
public void tearDownInstance() {
tickTearInstance = TICKER.incrementAndGet();
Assert.assertTrue("Setup/instance called before setup/iteration", tickSetInstance < tickSetIteration);
Assert.assertTrue("Setup/iteration called before setup/invocation", tickSetIteration < tickSetInvocation);
Assert.assertTrue("Setup/invocation called before run", tickSetInvocation < tickRun);
Assert.assertTrue("Run called before tear/invocation", tickRun < tickTearInvocation);
Assert.assertTrue("Tear/invocation called before tear/iteration", tickTearInvocation < tickTearIteration);
Assert.assertTrue("Tear/iteration called before tear/instance", tickTearIteration < tickTearInstance);
}
项目:alog
文件:AlogBenchmark.java
@TearDown(Level.Iteration)
public void stop() {
//We're NOT testing the time it take to process the log record, only how much
//time an application spends submitting them.
((AsyncLogHandler) log.getHandlers()[0]).clearBacklog();
}
项目:mumu-benchmark
文件:JMHSample_33_SecurityManager.java
@TearDown
public void tearDown() {
System.setSecurityManager(null);
}
项目:mumu-benchmark
文件:JMHSample_29_StatesDAG.java
@TearDown
public synchronized void tearDown() {
for (Counter c : all) {
c.dispose();
}
}
项目:beanvalidation-benchmark
文件:ParsingBeansSpeedBenchmark.java
@TearDown(Level.Iteration)
public void teardown() {
validatorFactory.close();
}
项目:centraldogma
文件:GitRepositoryBenchmark.java
@TearDown
public void destroy() throws Exception {
repo.close();
Util.deleteFileTree(repoDir);
}
项目:hekate
文件:MultiNodeBenchmarkContext.java
@TearDown
public void tearDown() {
nodes.forEach(n -> n.leaveAsync().join());
}
项目:org.ops4j.pax.transx
文件:PreparedStatementBench.java
@TearDown(Level.Iteration)
public void teardown() throws SQLException
{
connection.close();
}