Author: mreutegg
Date: Tue Apr  9 10:24:18 2019
New Revision: 1857159

URL: http://svn.apache.org/viewvc?rev=1857159&view=rev
Log:
OAK-8205: Add benchmark for Node.isNodeType()

Added:
    
jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/IsNodeTypeTest.java
   (with props)
Modified:
    
jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java

Modified: 
jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java?rev=1857159&r1=1857158&r2=1857159&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
 Tue Apr  9 10:24:18 2019
@@ -500,7 +500,8 @@ public class BenchmarkRunner {
             new PersistentCacheTest(statsProvider),
             new StringWriteTest(),
             new BasicWriteTest(),
-            new CanReadNonExisting()
+            new CanReadNonExisting(),
+            new IsNodeTypeTest()
         };
 
         Set<String> argset = Sets.newHashSet(nonOption.values(options));

Added: 
jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/IsNodeTypeTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/IsNodeTypeTest.java?rev=1857159&view=auto
==============================================================================
--- 
jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/IsNodeTypeTest.java
 (added)
+++ 
jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/IsNodeTypeTest.java
 Tue Apr  9 10:24:18 2019
@@ -0,0 +1,73 @@
+/*
+ * 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 javax.jcr.Node;
+import javax.jcr.Session;
+
+/**
+ * Benchmark for Node.isNodeType(String).
+ */
+public class IsNodeTypeTest extends AbstractTest<Node> {
+
+    private static final String NT_FOLDER = "nt:folder";
+
+    private String testNodeName = "test" + TEST_ID;
+
+    private Node testNode;
+
+    @Override
+    public void beforeSuite() throws Exception {
+        Session session = getRepository().login(getCredentials());
+        session.getRootNode().addNode(testNodeName, NT_FOLDER);
+        session.save();
+        session.logout();
+        testNode = prepareThreadExecutionContext();
+    }
+
+    @Override
+    public void afterSuite() throws Exception {
+        Session session = getRepository().login(getCredentials());
+        session.getRootNode().getNode(testNodeName).remove();
+        session.save();
+        session.logout();
+        disposeThreadExecutionContext(testNode);
+    }
+
+    @Override
+    protected Node prepareThreadExecutionContext() throws Exception {
+        return loginWriter().getRootNode().getNode(testNodeName);
+    }
+
+    @Override
+    protected void disposeThreadExecutionContext(Node context)
+            throws Exception {
+        context.getSession().logout();
+    }
+
+    @Override
+    protected void runTest(Node executionContext) throws Exception {
+        for (int i = 0; i < 100000; i++) {
+            executionContext.isNodeType(NT_FOLDER);
+        }
+    }
+
+    @Override
+    protected void runTest() throws Exception {
+        runTest(testNode);
+    }
+}

Propchange: 
jackrabbit/oak/trunk/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/IsNodeTypeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to