Fix checkstyle issues to enforce it
[controller.git] / opendaylight / md-sal / benchmark-data-store / src / main / java / org / opendaylight / controller / md / sal / dom / store / benchmark / InMemoryDataStoreWithSameThreadedExecutorBenchmark.java
1 /*
2  * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.md.sal.dom.store.benchmark;
9
10 import java.util.concurrent.ExecutorService;
11 import java.util.concurrent.TimeUnit;
12 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
13 import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
14 import org.openjdk.jmh.annotations.BenchmarkMode;
15 import org.openjdk.jmh.annotations.Fork;
16 import org.openjdk.jmh.annotations.Level;
17 import org.openjdk.jmh.annotations.Mode;
18 import org.openjdk.jmh.annotations.OutputTimeUnit;
19 import org.openjdk.jmh.annotations.Scope;
20 import org.openjdk.jmh.annotations.Setup;
21 import org.openjdk.jmh.annotations.State;
22 import org.openjdk.jmh.annotations.TearDown;
23
24 /**
25  * Benchmark for testing of performance of write operations for
26  * InMemoryDataStore. The instance of benchmark creates InMemoryDataStore with
27  * Data Change Listener Executor Service as Blocking Bounded Fast Thread Pool
28  * and DOM Store Executor Service as Same Thread Executor.
29  *
30  * @author Lukas Sedlak
31  */
32 @State(Scope.Thread)
33 @BenchmarkMode(Mode.AverageTime)
34 @OutputTimeUnit(TimeUnit.MILLISECONDS)
35 @Fork(1)
36 public class InMemoryDataStoreWithSameThreadedExecutorBenchmark
37         extends AbstractInMemoryDatastoreWriteTransactionBenchmark {
38
39     private static final int MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE = 20;
40     private static final int MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE = 1000;
41
42     @Override
43     @Setup(Level.Trial)
44     public void setUp() throws Exception {
45         final String name = "DS_BENCHMARK";
46         final ExecutorService dataChangeListenerExecutor = SpecialExecutors.newBlockingBoundedFastThreadPool(
47                 MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE, MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE, name + "-DCL");
48
49         domStore = new InMemoryDOMDataStore("SINGLE_THREADED_DS_BENCHMARK", dataChangeListenerExecutor);
50         schemaContext = BenchmarkModel.createTestContext();
51         domStore.onGlobalContextUpdated(schemaContext);
52         initTestNode();
53     }
54
55     @Override
56     @TearDown
57     public void tearDown() {
58         schemaContext = null;
59         domStore = null;
60     }
61 }