2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.md.sal.dom.store.benchmark;
10 import com.google.common.util.concurrent.MoreExecutors;
11 import java.util.concurrent.ExecutorService;
12 import java.util.concurrent.TimeUnit;
13 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
14 import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
15 import org.openjdk.jmh.annotations.Level;
16 import org.openjdk.jmh.annotations.Setup;
17 import org.openjdk.jmh.annotations.TearDown;
18 import org.openjdk.jmh.annotations.Fork;
19 import org.openjdk.jmh.annotations.Scope;
20 import org.openjdk.jmh.annotations.State;
21 import org.openjdk.jmh.annotations.BenchmarkMode;
22 import org.openjdk.jmh.annotations.Mode;
23 import org.openjdk.jmh.annotations.OutputTimeUnit;
26 * Benchmark for testing of performance of write operations for InMemoryDataStore. The instance
27 * of benchmark creates InMemoryDataStore with Data Change Listener Executor Service as Blocking Bounded Fast Thread Pool
28 * and DOM Store Executor Service as Same Thread Executor.
30 * @author Lukas Sedlak <lsedlak@cisco.com>
33 @BenchmarkMode(Mode.AverageTime)
34 @OutputTimeUnit(TimeUnit.MILLISECONDS)
36 public class InMemoryDataStoreWithSameThreadedExecutorBenchmark extends AbstractInMemoryDatastoreWriteTransactionBenchmark {
38 private static final int MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE = 20;
39 private static final int MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE = 1000;
42 public void setUp() throws Exception {
43 final String name = "DS_BENCHMARK";
44 final ExecutorService dataChangeListenerExecutor = SpecialExecutors.newBlockingBoundedFastThreadPool(
45 MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE, MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE, name + "-DCL");
47 domStore = new InMemoryDOMDataStore("SINGLE_THREADED_DS_BENCHMARK", MoreExecutors.sameThreadExecutor(),
48 dataChangeListenerExecutor);
49 schemaContext = BenchmarkModel.createTestContext();
50 domStore.onGlobalContextUpdated(schemaContext);
55 public void tearDown() {