2 * Copyright (c) 2014 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.collect.ImmutableMap;
11 import com.google.common.util.concurrent.ListeningExecutorService;
12 import com.google.common.util.concurrent.MoreExecutors;
14 import java.util.concurrent.Executors;
15 import java.util.concurrent.ThreadPoolExecutor;
16 import java.util.concurrent.TimeUnit;
17 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
18 import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
19 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
20 import org.opendaylight.controller.sal.core.spi.data.DOMStore;
21 import org.openjdk.jmh.annotations.BenchmarkMode;
22 import org.openjdk.jmh.annotations.Fork;
23 import org.openjdk.jmh.annotations.Level;
24 import org.openjdk.jmh.annotations.Mode;
25 import org.openjdk.jmh.annotations.OutputTimeUnit;
26 import org.openjdk.jmh.annotations.Scope;
27 import org.openjdk.jmh.annotations.Setup;
28 import org.openjdk.jmh.annotations.State;
31 @BenchmarkMode(Mode.AverageTime)
32 @OutputTimeUnit(TimeUnit.MILLISECONDS)
34 public class InMemoryBrokerWriteTransactionBenchmark extends AbstractInMemoryBrokerWriteTransactionBenchmark {
35 private ListeningExecutorService executor;
39 public void setUp() throws Exception {
40 ListeningExecutorService dsExec = MoreExecutors.sameThreadExecutor();
41 executor = MoreExecutors.listeningDecorator(
42 MoreExecutors.getExitingExecutorService((ThreadPoolExecutor)Executors.newFixedThreadPool(1), 1L, TimeUnit.SECONDS));
44 InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", dsExec);
45 InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", dsExec);
46 Map<LogicalDatastoreType, DOMStore> datastores = ImmutableMap.of(
47 LogicalDatastoreType.OPERATIONAL, (DOMStore)operStore,
48 LogicalDatastoreType.CONFIGURATION, configStore);
50 domBroker = new SerializedDOMDataBroker(datastores, executor);
51 schemaContext = BenchmarkModel.createTestContext();
52 configStore.onGlobalContextUpdated(schemaContext);
53 operStore.onGlobalContextUpdated(schemaContext);
58 public void tearDown() {