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;
11 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
12 import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
13 import org.opendaylight.mdsal.dom.broker.SerializedDOMDataBroker;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15 import org.openjdk.jmh.annotations.Benchmark;
16 import org.openjdk.jmh.annotations.Measurement;
17 import org.openjdk.jmh.annotations.Warmup;
20 * Abstract class to handle transaction benchmarks.
22 * @author Lukas Sedlak
24 public abstract class AbstractInMemoryBrokerWriteTransactionBenchmark
25 extends AbstractInMemoryWriteTransactionBenchmark {
27 protected SerializedDOMDataBroker domBroker;
29 protected void initTestNode() throws Exception {
30 final YangInstanceIdentifier testPath = YangInstanceIdentifier.builder(BenchmarkModel.TEST_PATH).build();
31 DOMDataTreeReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
32 writeTx.put(LogicalDatastoreType.OPERATIONAL, testPath, provideOuterListNode());
34 writeTx.commit().get();
38 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
39 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
40 public void write100KSingleNodeWithOneInnerItemInOneCommitBenchmark() throws Exception {
42 DOMDataTreeReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
43 for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) {
44 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_100K_PATHS[outerListKey],
45 OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]);
48 writeTx.commit().get();
52 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
53 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
54 public void write100KSingleNodeWithOneInnerItemInCommitPerWriteBenchmark() throws Exception {
55 for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) {
56 DOMDataTreeReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
57 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_100K_PATHS[outerListKey],
58 OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]);
60 writeTx.commit().get();
65 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
66 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
67 public void write50KSingleNodeWithTwoInnerItemsInOneCommitBenchmark() throws Exception {
68 DOMDataTreeReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
69 for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
70 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_50K_PATHS[outerListKey],
71 OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]);
74 writeTx.commit().get();
78 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
79 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
80 public void write50KSingleNodeWithTwoInnerItemsInCommitPerWriteBenchmark() throws Exception {
81 for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
82 DOMDataTreeReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
83 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_50K_PATHS[outerListKey],
84 OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]);
85 writeTx.commit().get();
90 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
91 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
92 public void write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark() throws Exception {
93 DOMDataTreeReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
94 for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
95 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_10K_PATHS[outerListKey],
96 OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
98 writeTx.commit().get();
102 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
103 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
104 public void write10KSingleNodeWithTenInnerItemsInCommitPerWriteBenchmark() throws Exception {
105 for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
106 DOMDataTreeReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
107 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_10K_PATHS[outerListKey],
108 OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
109 writeTx.commit().get();