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.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
12 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
13 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
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 for in-memory Datastore transaction benchmarks.
22 * @author Lukas Sedlak
24 public abstract class AbstractInMemoryDatastoreWriteTransactionBenchmark
25 extends AbstractInMemoryWriteTransactionBenchmark {
27 protected InMemoryDOMDataStore domStore;
29 protected void initTestNode() throws Exception {
30 final YangInstanceIdentifier testPath = YangInstanceIdentifier.builder(BenchmarkModel.TEST_PATH).build();
31 DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
32 writeTx.write(testPath, provideOuterListNode());
34 DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
35 cohort.canCommit().get();
36 cohort.preCommit().get();
37 cohort.commit().get();
41 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
42 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
43 public void write100KSingleNodeWithOneInnerItemInOneCommitBenchmark() throws Exception {
44 DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
45 for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) {
46 writeTx.write(OUTER_LIST_100K_PATHS[outerListKey], OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]);
48 DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
49 cohort.canCommit().get();
50 cohort.preCommit().get();
51 cohort.commit().get();
55 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
56 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
57 public void write100KSingleNodeWithOneInnerItemInCommitPerWriteBenchmark() throws Exception {
58 for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) {
59 DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
60 writeTx.write(OUTER_LIST_100K_PATHS[outerListKey], OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]);
62 DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
63 cohort.canCommit().get();
64 cohort.preCommit().get();
65 cohort.commit().get();
70 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
71 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
72 public void write50KSingleNodeWithTwoInnerItemsInOneCommitBenchmark() throws Exception {
73 DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
74 for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
75 writeTx.write(OUTER_LIST_50K_PATHS[outerListKey], OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]);
77 DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
78 cohort.canCommit().get();
79 cohort.preCommit().get();
80 cohort.commit().get();
84 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
85 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
86 public void write50KSingleNodeWithTwoInnerItemsInCommitPerWriteBenchmark() throws Exception {
87 for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
88 DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
89 writeTx.write(OUTER_LIST_50K_PATHS[outerListKey], OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]);
90 DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
91 cohort.canCommit().get();
92 cohort.preCommit().get();
93 cohort.commit().get();
98 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
99 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
100 public void write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark() throws Exception {
101 DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
102 for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
103 writeTx.write(OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
105 DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
106 cohort.canCommit().get();
107 cohort.preCommit().get();
108 cohort.commit().get();
112 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
113 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
114 public void write10KSingleNodeWithTenInnerItemsInCommitPerWriteBenchmark() throws Exception {
115 for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
116 DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
117 writeTx.write(OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
118 DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
119 cohort.canCommit().get();
120 cohort.preCommit().get();
121 cohort.commit().get();