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;
11 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
12 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
13 import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataBrokerImpl;
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 * @author Lukas Sedlak <lsedlak@cisco.com>
22 public abstract class AbstractInMemoryBrokerWriteTransactionBenchmark extends AbstractInMemoryWriteTransactionBenchmark {
24 protected DOMDataBrokerImpl domBroker;
26 protected void initTestNode() throws Exception {
27 final YangInstanceIdentifier testPath = YangInstanceIdentifier.builder(BenchmarkModel.TEST_PATH)
29 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
30 writeTx.put(LogicalDatastoreType.OPERATIONAL, testPath, provideOuterListNode());
32 writeTx.submit().get();
36 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
37 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
38 public void write100KSingleNodeWithOneInnerItemInOneCommitBenchmark() throws Exception {
40 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
41 for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) {
42 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_100K_PATHS[outerListKey], OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]);
45 writeTx.submit().get();
49 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
50 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
51 public void write100KSingleNodeWithOneInnerItemInCommitPerWriteBenchmark() throws Exception {
52 for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) {
53 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
54 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_100K_PATHS[outerListKey], OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]);
56 writeTx.submit().get();
61 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
62 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
63 public void write50KSingleNodeWithTwoInnerItemsInOneCommitBenchmark() throws Exception {
64 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
65 for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
66 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_50K_PATHS[outerListKey], OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]);
69 writeTx.submit().get();
73 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
74 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
75 public void write50KSingleNodeWithTwoInnerItemsInCommitPerWriteBenchmark() throws Exception {
76 for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
77 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
78 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_50K_PATHS[outerListKey], OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]);
79 writeTx.submit().get();
84 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
85 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
86 public void write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark() throws Exception {
87 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
88 for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
89 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
91 writeTx.submit().get();
95 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
96 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
97 public void write10KSingleNodeWithTenInnerItemsInCommitPerWriteBenchmark() throws Exception {
98 for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
99 DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
100 writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
101 writeTx.submit().get();