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 java.util.concurrent.TimeUnit;
12 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
13 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
14 import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.openjdk.jmh.annotations.Benchmark;
17 import org.openjdk.jmh.annotations.Measurement;
18 import org.openjdk.jmh.annotations.Warmup;
21 * @author Lukas Sedlak <lsedlak@cisco.com>
23 public abstract class AbstractInMemoryBrokerWriteTransactionBenchmark extends AbstractInMemoryWriteTransactionBenchmark {
25 protected SerializedDOMDataBroker domBroker;
27 protected void initTestNode() throws Exception {
28 final YangInstanceIdentifier testPath = YangInstanceIdentifier.builder(BenchmarkModel.TEST_PATH)
30 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
31 writeTx.put(LogicalDatastoreType.OPERATIONAL, testPath, provideOuterListNode());
33 writeTx.submit().get();
37 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
38 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
39 public void write100KSingleNodeWithOneInnerItemInOneCommitBenchmark() throws Exception {
41 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
42 for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) {
43 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_100K_PATHS[outerListKey], OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]);
46 writeTx.submit().get();
50 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
51 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
52 public void write100KSingleNodeWithOneInnerItemInCommitPerWriteBenchmark() throws Exception {
53 for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) {
54 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
55 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_100K_PATHS[outerListKey], OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]);
57 writeTx.submit().get();
62 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
63 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
64 public void write50KSingleNodeWithTwoInnerItemsInOneCommitBenchmark() throws Exception {
65 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
66 for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
67 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_50K_PATHS[outerListKey], OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]);
70 writeTx.submit().get();
74 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
75 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
76 public void write50KSingleNodeWithTwoInnerItemsInCommitPerWriteBenchmark() throws Exception {
77 for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
78 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
79 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_50K_PATHS[outerListKey], OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]);
80 writeTx.submit().get();
85 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
86 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
87 public void write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark() throws Exception {
88 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
89 for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
90 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
92 writeTx.submit().get();
96 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
97 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
98 public void write10KSingleNodeWithTenInnerItemsInCommitPerWriteBenchmark() throws Exception {
99 for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
100 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
101 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
102 writeTx.submit().get();