Merge "BUG 1853 : Clustered Data Store causes Out of Memory"
[controller.git] / opendaylight / md-sal / benchmark-data-store / src / main / java / org / opendaylight / controller / md / sal / dom / store / benchmark / InMemoryDataStoreWriteTransactionBenchmark.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 com.google.common.util.concurrent.MoreExecutors;
11 import java.util.concurrent.TimeUnit;
12 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
13 import org.openjdk.jmh.annotations.Fork;
14 import org.openjdk.jmh.annotations.Scope;
15 import org.openjdk.jmh.annotations.State;
16 import org.openjdk.jmh.annotations.BenchmarkMode;
17 import org.openjdk.jmh.annotations.Mode;
18 import org.openjdk.jmh.annotations.OutputTimeUnit;
19 import org.openjdk.jmh.annotations.Setup;
20 import org.openjdk.jmh.annotations.Level;
21 import org.openjdk.jmh.annotations.TearDown;
22
23 /**
24  * Benchmark for testing of performance of write operations for InMemoryDataStore. The instance
25  * of benchmark creates InMemoryDataStore with Data Change Listener Executor Service as Same Thread Executor
26  * and DOM Store Executor Service as Same Thread Executor.
27  *
28  * @author Lukas Sedlak <lsedlak@cisco.com>
29  */
30 @State(Scope.Thread)
31 @BenchmarkMode(Mode.AverageTime)
32 @OutputTimeUnit(TimeUnit.MILLISECONDS)
33 @Fork(1)
34 public class InMemoryDataStoreWriteTransactionBenchmark extends AbstractInMemoryDatastoreWriteTransactionBenchmark {
35
36     @Setup(Level.Trial)
37     public void setUp() throws Exception {
38         domStore = new InMemoryDOMDataStore("SINGLE_THREADED_DS_BENCHMARK", MoreExecutors.sameThreadExecutor(),
39             MoreExecutors.sameThreadExecutor());
40         schemaContext = BenchmarkModel.createTestContext();
41         domStore.onGlobalContextUpdated(schemaContext);
42         initTestNode();
43     }
44
45     @TearDown
46     public void tearDown() {
47         schemaContext = null;
48         domStore = null;
49     }
50 }