2 * Copyright (c) 2013, 2017 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 * Abstract class to handle transaction benchmarks.
23 * @author Lukas Sedlak
25 public abstract class AbstractInMemoryBrokerWriteTransactionBenchmark
26 extends AbstractInMemoryWriteTransactionBenchmark {
28 protected SerializedDOMDataBroker domBroker;
30 protected void initTestNode() throws Exception {
31 final YangInstanceIdentifier testPath = YangInstanceIdentifier.builder(BenchmarkModel.TEST_PATH).build();
32 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
33 writeTx.put(LogicalDatastoreType.OPERATIONAL, testPath, provideOuterListNode());
35 writeTx.submit().get();
39 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
40 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
41 public void write100KSingleNodeWithOneInnerItemInOneCommitBenchmark() throws Exception {
43 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
44 for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) {
45 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_100K_PATHS[outerListKey],
46 OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]);
49 writeTx.submit().get();
53 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
54 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
55 public void write100KSingleNodeWithOneInnerItemInCommitPerWriteBenchmark() throws Exception {
56 for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) {
57 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
58 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_100K_PATHS[outerListKey],
59 OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]);
61 writeTx.submit().get();
66 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
67 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
68 public void write50KSingleNodeWithTwoInnerItemsInOneCommitBenchmark() throws Exception {
69 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
70 for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
71 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_50K_PATHS[outerListKey],
72 OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]);
75 writeTx.submit().get();
79 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
80 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
81 public void write50KSingleNodeWithTwoInnerItemsInCommitPerWriteBenchmark() throws Exception {
82 for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
83 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
84 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_50K_PATHS[outerListKey],
85 OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]);
86 writeTx.submit().get();
91 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
92 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
93 public void write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark() throws Exception {
94 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
95 for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
96 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_10K_PATHS[outerListKey],
97 OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
99 writeTx.submit().get();
103 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
104 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
105 public void write10KSingleNodeWithTenInnerItemsInCommitPerWriteBenchmark() throws Exception {
106 for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
107 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
108 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_10K_PATHS[outerListKey],
109 OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
110 writeTx.submit().get();