Fixed compilation error in Eclipse.
[controller.git] / opendaylight / md-sal / benchmark-data-store / src / main / java / org / opendaylight / controller / md / sal / dom / store / benchmark / AbstractInMemoryBrokerWriteTransactionBenchmark.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.md.sal.dom.store.benchmark;
9
10 import java.util.concurrent.TimeUnit;
11
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;
19
20 /**
21  * @author Lukas Sedlak <lsedlak@cisco.com>
22  */
23 public abstract class AbstractInMemoryBrokerWriteTransactionBenchmark extends AbstractInMemoryWriteTransactionBenchmark {
24
25     protected SerializedDOMDataBroker domBroker;
26
27     protected void initTestNode() throws Exception {
28         final YangInstanceIdentifier testPath = YangInstanceIdentifier.builder(BenchmarkModel.TEST_PATH)
29             .build();
30         DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
31         writeTx.put(LogicalDatastoreType.OPERATIONAL, testPath, provideOuterListNode());
32
33         writeTx.submit().get();
34     }
35
36     @Benchmark
37     @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
38     @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
39     public void write100KSingleNodeWithOneInnerItemInOneCommitBenchmark() throws Exception {
40
41         DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
42         for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) {
43             writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_100K_PATHS[outerListKey], OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]);
44         }
45
46         writeTx.submit().get();
47     }
48
49     @Benchmark
50     @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
51     @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
52     public void write100KSingleNodeWithOneInnerItemInCommitPerWriteBenchmark() throws Exception {
53         for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) {
54             DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
55             writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_100K_PATHS[outerListKey], OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]);
56
57             writeTx.submit().get();
58         }
59     }
60
61     @Benchmark
62     @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
63     @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
64     public void write50KSingleNodeWithTwoInnerItemsInOneCommitBenchmark() throws Exception {
65         DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
66         for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
67             writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_50K_PATHS[outerListKey], OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]);
68         }
69
70         writeTx.submit().get();
71     }
72
73     @Benchmark
74     @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
75     @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
76     public void write50KSingleNodeWithTwoInnerItemsInCommitPerWriteBenchmark() throws Exception {
77         for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
78             DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
79             writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_50K_PATHS[outerListKey], OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]);
80             writeTx.submit().get();
81         }
82     }
83
84     @Benchmark
85     @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
86     @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
87     public void write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark() throws Exception {
88         DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
89         for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
90             writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
91         }
92         writeTx.submit().get();
93     }
94
95     @Benchmark
96     @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
97     @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
98     public void write10KSingleNodeWithTenInnerItemsInCommitPerWriteBenchmark() throws Exception {
99         for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
100             DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
101             writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
102             writeTx.submit().get();
103         }
104     }
105 }