From 964192f2a4be7a227acea644250e26a356de3933 Mon Sep 17 00:00:00 2001 From: Lukas Sedlak Date: Wed, 3 Sep 2014 14:37:43 +0200 Subject: [PATCH] Added methods for benchmarking of commit/write ops Added methods for benchmarking of efficiency of InMemoryDataTree for commits after each write. Scenarios remain the same. Change-Id: I71527f78d7762ba7baf7a7bef6471c2c81c26db0 Signed-off-by: Lukas Sedlak --- .../impl/tree/InMemoryDataTreeBenchmark.java | 58 ++++++++++++++----- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/benchmarks/src/main/java/org/opendaylight/yangtools/yang/data/impl/tree/InMemoryDataTreeBenchmark.java b/benchmarks/src/main/java/org/opendaylight/yangtools/yang/data/impl/tree/InMemoryDataTreeBenchmark.java index 306c14dc07..a9171687cf 100644 --- a/benchmarks/src/main/java/org/opendaylight/yangtools/yang/data/impl/tree/InMemoryDataTreeBenchmark.java +++ b/benchmarks/src/main/java/org/opendaylight/yangtools/yang/data/impl/tree/InMemoryDataTreeBenchmark.java @@ -141,14 +141,10 @@ public class InMemoryDataTreeBenchmark { @Benchmark @Warmup(iterations = 10, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 20, timeUnit = TimeUnit.MILLISECONDS) - public void singleNodes100KWriteBenchmark() throws Exception { - applyWriteSingleNode(OUTER_LIST_100K); - } - - private void applyWriteSingleNode(final int reps) throws DataValidationFailedException { + public void write100KSingleNodeWithOneInnerItemInOneCommitBenchmark() throws Exception { final DataTreeSnapshot snapshot = datastore.takeSnapshot(); final DataTreeModification modification = snapshot.newModification(); - for (int outerListKey = 0; outerListKey < reps; ++outerListKey) { + for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) { modification.write(OUTER_LIST_100K_PATHS[outerListKey], OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]); } datastore.validate(modification); @@ -159,14 +155,24 @@ public class InMemoryDataTreeBenchmark { @Benchmark @Warmup(iterations = 10, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 20, timeUnit = TimeUnit.MILLISECONDS) - public void twoNodes50KWriteBenchmark() throws Exception { - applyWriteTwoNodes(OUTER_LIST_50K); + public void write100KSingleNodeWithOneInnerItemInCommitPerWriteBenchmark() throws Exception { + final DataTreeSnapshot snapshot = datastore.takeSnapshot(); + for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) { + final DataTreeModification modification = snapshot.newModification(); + modification.write(OUTER_LIST_100K_PATHS[outerListKey], OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]); + datastore.validate(modification); + final DataTreeCandidate candidate = datastore.prepare(modification); + datastore.commit(candidate); + } } - private void applyWriteTwoNodes(final int reps) throws DataValidationFailedException { + @Benchmark + @Warmup(iterations = 10, timeUnit = TimeUnit.MILLISECONDS) + @Measurement(iterations = 20, timeUnit = TimeUnit.MILLISECONDS) + public void write50KSingleNodeWithTwoInnerItemsInOneCommitBenchmark() throws Exception { final DataTreeSnapshot snapshot = datastore.takeSnapshot(); final DataTreeModification modification = snapshot.newModification(); - for (int outerListKey = 0; outerListKey < reps; ++outerListKey) { + for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) { modification.write(OUTER_LIST_50K_PATHS[outerListKey], OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]); } datastore.validate(modification); @@ -177,18 +183,42 @@ public class InMemoryDataTreeBenchmark { @Benchmark @Warmup(iterations = 10, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 20, timeUnit = TimeUnit.MILLISECONDS) - public void tenNodes10KWriteBenchmark() throws Exception { - applyWriteTenNodes(OUTER_LIST_10K); + public void write50KSingleNodeWithTwoInnerItemsInCommitPerWriteBenchmark() throws Exception { + final DataTreeSnapshot snapshot = datastore.takeSnapshot(); + for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) { + final DataTreeModification modification = snapshot.newModification(); + modification.write(OUTER_LIST_50K_PATHS[outerListKey], OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]); + datastore.validate(modification); + final DataTreeCandidate candidate = datastore.prepare(modification); + datastore.commit(candidate); + } } - private void applyWriteTenNodes(final int reps) throws DataValidationFailedException { + @Benchmark + @Warmup(iterations = 10, timeUnit = TimeUnit.MILLISECONDS) + @Measurement(iterations = 20, timeUnit = TimeUnit.MILLISECONDS) + public void write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark() throws Exception { final DataTreeSnapshot snapshot = datastore.takeSnapshot(); final DataTreeModification modification = snapshot.newModification(); - for (int outerListKey = 0; outerListKey < reps; ++outerListKey) { + for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) { modification.write(OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]); } datastore.validate(modification); final DataTreeCandidate candidate = datastore.prepare(modification); datastore.commit(candidate); } + + @Benchmark + @Warmup(iterations = 10, timeUnit = TimeUnit.MILLISECONDS) + @Measurement(iterations = 20, timeUnit = TimeUnit.MILLISECONDS) + public void write10KSingleNodeWithTenInnerItemsInCommitPerWriteBenchmark() throws Exception { + final DataTreeSnapshot snapshot = datastore.takeSnapshot(); + for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) { + final DataTreeModification modification = snapshot.newModification(); + modification.write(OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]); + datastore.validate(modification); + final DataTreeCandidate candidate = datastore.prepare(modification); + datastore.commit(candidate); + } + } } -- 2.36.6