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.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 * @author Lukas Sedlak <lsedlak@cisco.com>
22 public abstract class AbstractInMemoryDatastoreWriteTransactionBenchmark extends AbstractInMemoryWriteTransactionBenchmark {
24 protected InMemoryDOMDataStore domStore;
26 protected void initTestNode() throws Exception {
27 final YangInstanceIdentifier testPath = YangInstanceIdentifier.builder(BenchmarkModel.TEST_PATH)
29 DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
30 writeTx.write(testPath, provideOuterListNode());
32 DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
33 cohort.canCommit().get();
34 cohort.preCommit().get();
35 cohort.commit().get();
39 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
40 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
41 public void write100KSingleNodeWithOneInnerItemInOneCommitBenchmark() throws Exception {
42 DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
43 for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) {
44 writeTx.write(OUTER_LIST_100K_PATHS[outerListKey], OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]);
46 DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
47 cohort.canCommit().get();
48 cohort.preCommit().get();
49 cohort.commit().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 DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
58 writeTx.write(OUTER_LIST_100K_PATHS[outerListKey], OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]);
60 DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
61 cohort.canCommit().get();
62 cohort.preCommit().get();
63 cohort.commit().get();
68 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
69 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
70 public void write50KSingleNodeWithTwoInnerItemsInOneCommitBenchmark() throws Exception {
71 DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
72 for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
73 writeTx.write(OUTER_LIST_50K_PATHS[outerListKey], OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]);
75 DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
76 cohort.canCommit().get();
77 cohort.preCommit().get();
78 cohort.commit().get();
82 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
83 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
84 public void write50KSingleNodeWithTwoInnerItemsInCommitPerWriteBenchmark() throws Exception {
85 for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
86 DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
87 writeTx.write(OUTER_LIST_50K_PATHS[outerListKey], OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]);
88 DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
89 cohort.canCommit().get();
90 cohort.preCommit().get();
91 cohort.commit().get();
96 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
97 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
98 public void write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark() throws Exception {
99 DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
100 for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
101 writeTx.write(OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
103 DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
104 cohort.canCommit().get();
105 cohort.preCommit().get();
106 cohort.commit().get();
110 @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
111 @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
112 public void write10KSingleNodeWithTenInnerItemsInCommitPerWriteBenchmark() throws Exception {
113 for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
114 DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
115 writeTx.write(OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
116 DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
117 cohort.canCommit().get();
118 cohort.preCommit().get();
119 cohort.commit().get();