You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by an...@apache.org on 2022/10/19 15:33:49 UTC
[jackrabbit-oak] branch trunk updated: OAK-9969 : Benchmark for OAK-9966
This is an automated email from the ASF dual-hosted git repository.
angela pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new 169fbb090a OAK-9969 : Benchmark for OAK-9966
169fbb090a is described below
commit 169fbb090ae33cb65f47481c477a783dd1b283fc
Author: angela <an...@adobe.com>
AuthorDate: Wed Oct 19 17:33:39 2022 +0200
OAK-9969 : Benchmark for OAK-9966
---
.../jackrabbit/oak/benchmark/BenchmarkRunner.java | 4 +
.../IsCheckedOutAddMixinSetPropertyTest.java | 101 +++++++++++++++++++++
2 files changed, 105 insertions(+)
diff --git a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
index aaac39bee1..22392fc5d7 100644
--- a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
+++ b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
@@ -305,6 +305,10 @@ public class BenchmarkRunner {
benchmarkOptions.getNumberOfGroups().value(options),
benchmarkOptions.getReport().value(options),
benchmarkOptions.getEvalutionType().value(options)),
+ new IsCheckedOutAddMixinSetPropertyTest(
+ benchmarkOptions.getRunAsAdmin().value(options),
+ benchmarkOptions.getItemsToRead().value(options),
+ benchmarkOptions.getReport().value(options)),
new ConcurrentReadDeepTreeTest(
benchmarkOptions.getRunAsAdmin().value(options),
benchmarkOptions.getItemsToRead().value(options),
diff --git a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/IsCheckedOutAddMixinSetPropertyTest.java b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/IsCheckedOutAddMixinSetPropertyTest.java
new file mode 100644
index 0000000000..f24bbf461a
--- /dev/null
+++ b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/IsCheckedOutAddMixinSetPropertyTest.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.benchmark;
+
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.jetbrains.annotations.NotNull;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkState;
+
+public class IsCheckedOutAddMixinSetPropertyTest extends ReadDeepTreeTest {
+
+ public IsCheckedOutAddMixinSetPropertyTest(boolean runAsAdmin, int itemsToRead, boolean doReport) {
+ super(runAsAdmin, itemsToRead, doReport);
+ }
+
+ @Override
+ protected void randomRead(Session testSession, List<String> allPaths, int cnt) throws RepositoryException {
+ boolean logout = false;
+ if (testSession == null) {
+ testSession = getTestSession();
+ logout = true;
+ }
+ try {
+ Cnt accessCnt = new Cnt();
+ long start = System.currentTimeMillis();
+ for (int i = 0; i < cnt; i++) {
+ readItem(testSession, getRandom(allPaths), accessCnt);
+ }
+ long end = System.currentTimeMillis();
+ if (doReport) {
+ System.out.println("Session " + testSession.getUserID() + " reading " + (cnt-accessCnt.noAccess) + " (Nodes: "+ accessCnt.nodeCnt +"; Properties: "+accessCnt.propertyCnt+"), Node writes "+accessCnt.nodeWrites+" completed in " + (end - start));
+ }
+ } finally {
+ if (logout) {
+ logout(testSession);
+ }
+ }
+ }
+
+ private void readItem(Session testSession, String path, Cnt accessCnt) throws RepositoryException {
+ for (int i = 0; i < repeatedRead; i++) {
+ JackrabbitSession s = (JackrabbitSession) testSession;
+ Item item = s.getItemOrNull(path);
+ if (item instanceof Node) {
+ accessCnt.nodeCnt++;
+ additionalNodeOperation((Node) item, accessCnt);
+ } else if (item instanceof Property) {
+ accessCnt.propertyCnt++;
+ Node parent = s.getParentOrNull(item);
+ if (parent != null) {
+ additionalNodeOperation(parent, accessCnt);
+ }
+ } else {
+ accessCnt.noAccess++;
+ }
+ }
+ }
+
+ private void additionalNodeOperation(@NotNull Node node, Cnt accessCnt) {
+ try {
+ checkState(node.isCheckedOut());
+ if (node.canAddMixin("mix:language")) {
+ accessCnt.nodeWrites++;
+ node.addMixin("mix:language");
+ node.setProperty("jcr:language", "en");
+ node.getSession().refresh(false);
+ }
+ } catch (RepositoryException repositoryException) {
+ throw new RuntimeException(repositoryException.getMessage());
+ }
+ }
+
+ private static final class Cnt {
+ private int nodeCnt = 0;
+ private int propertyCnt = 0;
+ private int nodeWrites = 0;
+ private int noAccess = 0;
+ }
+}
\ No newline at end of file