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.ListeningExecutorService;
11 import com.google.common.util.concurrent.MoreExecutors;
12 import java.util.concurrent.ExecutorService;
13 import java.util.concurrent.TimeUnit;
14 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
15 import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
16 import org.openjdk.jmh.annotations.BenchmarkMode;
17 import org.openjdk.jmh.annotations.Fork;
18 import org.openjdk.jmh.annotations.Level;
19 import org.openjdk.jmh.annotations.Mode;
20 import org.openjdk.jmh.annotations.OutputTimeUnit;
21 import org.openjdk.jmh.annotations.Scope;
22 import org.openjdk.jmh.annotations.Setup;
23 import org.openjdk.jmh.annotations.State;
24 import org.openjdk.jmh.annotations.TearDown;
27 * Benchmark for testing of performance of write operations for InMemoryDataStore. The instance
28 * of benchmark creates InMemoryDataStore with Data Change Listener Executor Service as BlockingBoundedFastThreadPool
29 * and DOM Store Executor Service as Blocking Bounded Fast Thread Pool.
31 * @see org.opendaylight.yangtools.util.concurrent.SpecialExecutors
32 * @see org.opendaylight.controller.md.sal.dom.store.benchmark.AbstractInMemoryDatastoreWriteTransactionBenchmark
34 * @author Lukas Sedlak <lsedlak@cisco.com>
37 @BenchmarkMode(Mode.AverageTime)
38 @OutputTimeUnit(TimeUnit.MILLISECONDS)
40 public class InMemoryDataStoreWithExecutorServiceBenchmark extends AbstractInMemoryDatastoreWriteTransactionBenchmark {
42 private static final int MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE = 20;
43 private static final int MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE = 1000;
44 private static final int MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE = 5000;
48 public void setUp() throws Exception {
49 final String name = "DS_BENCHMARK";
50 final ExecutorService dataChangeListenerExecutor = SpecialExecutors.newBlockingBoundedFastThreadPool(
51 MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE, MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE, name + "-DCL");
53 final ListeningExecutorService domStoreExecutor = MoreExecutors.listeningDecorator(SpecialExecutors.newBoundedSingleThreadExecutor(
54 MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE, "DOMStore-" + name ));
56 domStore = new InMemoryDOMDataStore(name, domStoreExecutor,
57 dataChangeListenerExecutor);
58 schemaContext = BenchmarkModel.createTestContext();
59 domStore.onGlobalContextUpdated(schemaContext);
65 public void tearDown() {