You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/02/11 15:19:57 UTC

incubator-tinkerpop git commit: Added performance test for groovy environment.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master e82de9f9e -> f6d1444b0


Added performance test for groovy environment.

Current focus is on analyzing the GremlinExecutor.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/f6d1444b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/f6d1444b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/f6d1444b

Branch: refs/heads/master
Commit: f6d1444b06692ea61a9e7c78dbff7a7e0d820544
Parents: e82de9f
Author: Stephen Mallette <sp...@apache.org>
Authored: Wed Feb 11 09:19:08 2015 -0500
Committer: Stephen Mallette <sp...@apache.org>
Committed: Wed Feb 11 09:19:08 2015 -0500

----------------------------------------------------------------------
 .../plugin/UtilitiesGremlinPluginScript.groovy  |  2 +-
 .../com/tinkerpop/gremlin/structure/Graph.java  |  1 +
 .../GroovyEnvironmentPerformanceSuite.java      | 87 ++++++++++++++++++++
 .../engine/GremlinExecutorPerformanceTest.java  | 57 +++++++++++++
 .../tinkergraph/structure/TinkerGraph.java      |  1 +
 ...erGraphGroovyEnvironmentPerformanceTest.java | 37 +++++++++
 6 files changed, 184 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f6d1444b/gremlin-console/src/main/resources/com/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPluginScript.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/resources/com/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPluginScript.groovy b/gremlin-console/src/main/resources/com/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPluginScript.groovy
index 0bcb84f..d4a2bbb 100644
--- a/gremlin-console/src/main/resources/com/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPluginScript.groovy
+++ b/gremlin-console/src/main/resources/com/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPluginScript.groovy
@@ -38,7 +38,7 @@ describeGraph = { Class<? extends com.tinkerpop.gremlin.structure.Graph> c ->
     return "${lf}" +
 "IMPLEMENTATION - ${c.getCanonicalName()} ${lf}" +
 "TINKERPOP TEST SUITE ${lf}" +
-"- Compliant with ($optInCount of 9 suites) + ${lf}" +
+"- Compliant with ($optInCount of 10 suites) + ${lf}" +
 "$suitesSupported ${lf}" +
 "- Opts out of $optOutCount individual tests ${lf}" +
 "$testsOptedOut ${lf}" +

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f6d1444b/gremlin-core/src/main/java/com/tinkerpop/gremlin/structure/Graph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/structure/Graph.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/structure/Graph.java
index 7f1c328..c663af2 100644
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/structure/Graph.java
+++ b/gremlin-core/src/main/java/com/tinkerpop/gremlin/structure/Graph.java
@@ -1119,6 +1119,7 @@ public interface Graph extends AutoCloseable {
         public static String SUITE_GROOVY_PROCESS_COMPUTER = "com.tinkerpop.gremlin.process.GroovyProcessComputerSuite";
         public static String SUITE_GROOVY_ENVIRONMENT = "com.tinkerpop.gremlin.groovy.GroovyEnvironmentSuite";
         public static String SUITE_GROOVY_ENVIRONMENT_INTEGRATE = "com.tinkerpop.gremlin.groovy.GroovyEnvironmentIntegrateSuite";
+        public static String SUITE_GROOVY_ENVIRONMENT_PERFORMANCE = "com.tinkerpop.gremlin.groovy.GroovyEnvironmentPerformanceSuite";
 
         /**
          * The test suite class to opt in to.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f6d1444b/gremlin-groovy-test/src/main/java/com/tinkerpop/gremlin/groovy/GroovyEnvironmentPerformanceSuite.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/com/tinkerpop/gremlin/groovy/GroovyEnvironmentPerformanceSuite.java b/gremlin-groovy-test/src/main/java/com/tinkerpop/gremlin/groovy/GroovyEnvironmentPerformanceSuite.java
new file mode 100644
index 0000000..d985bea
--- /dev/null
+++ b/gremlin-groovy-test/src/main/java/com/tinkerpop/gremlin/groovy/GroovyEnvironmentPerformanceSuite.java
@@ -0,0 +1,87 @@
+/*
+ * 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 com.tinkerpop.gremlin.groovy;
+
+import com.tinkerpop.gremlin.AbstractGremlinSuite;
+import com.tinkerpop.gremlin.AbstractGremlinTest;
+import com.tinkerpop.gremlin.GraphManager;
+import com.tinkerpop.gremlin.groovy.engine.GremlinExecutorPerformanceTest;
+import com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineIntegrateTest;
+import com.tinkerpop.gremlin.groovy.loaders.SugarLoader;
+import com.tinkerpop.gremlin.groovy.util.SugarTestHelper;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.RunnerBuilder;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class GroovyEnvironmentPerformanceSuite extends AbstractGremlinSuite {
+
+    private static final Class<?>[] allTests = new Class<?>[]{
+            GremlinExecutorPerformanceTest.class
+    };
+
+    /**
+     * This list of tests in the suite that will be executed.  Gremlin developers should add to this list
+     * as needed to enforce tests upon implementations.
+     */
+    private static final Class<?>[] testsToExecute;
+
+    static {
+        final String override = System.getenv().getOrDefault("gremlin.tests", "");
+        if (override.equals(""))
+            testsToExecute = allTests;
+        else {
+            final List<String> filters = Arrays.asList(override.split(","));
+            final List<Class<?>> allowed = Stream.of(allTests)
+                    .filter(c -> filters.contains(c.getName()))
+                    .collect(Collectors.toList());
+            testsToExecute = allowed.toArray(new Class<?>[allowed.size()]);
+        }
+    }
+
+    public GroovyEnvironmentPerformanceSuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError {
+        super(klass, builder, testsToExecute);
+    }
+
+    @Override
+    public boolean beforeTestExecution(final Class<? extends AbstractGremlinTest> testClass) {
+        unloadSugar();
+        SugarLoader.load();
+        return true;
+    }
+
+    @Override
+    public void afterTestExecution(final Class<? extends AbstractGremlinTest> testClass) {
+        unloadSugar();
+    }
+
+    private void unloadSugar() {
+        try {
+            SugarTestHelper.clearRegistry(GraphManager.get());
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f6d1444b/gremlin-groovy-test/src/main/java/com/tinkerpop/gremlin/groovy/engine/GremlinExecutorPerformanceTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/com/tinkerpop/gremlin/groovy/engine/GremlinExecutorPerformanceTest.java b/gremlin-groovy-test/src/main/java/com/tinkerpop/gremlin/groovy/engine/GremlinExecutorPerformanceTest.java
new file mode 100644
index 0000000..e05e6b0
--- /dev/null
+++ b/gremlin-groovy-test/src/main/java/com/tinkerpop/gremlin/groovy/engine/GremlinExecutorPerformanceTest.java
@@ -0,0 +1,57 @@
+package com.tinkerpop.gremlin.groovy.engine;
+
+import com.carrotsearch.junitbenchmarks.BenchmarkOptions;
+import com.carrotsearch.junitbenchmarks.BenchmarkRule;
+import com.carrotsearch.junitbenchmarks.annotation.AxisRange;
+import com.carrotsearch.junitbenchmarks.annotation.BenchmarkHistoryChart;
+import com.carrotsearch.junitbenchmarks.annotation.BenchmarkMethodChart;
+import com.carrotsearch.junitbenchmarks.annotation.LabelType;
+import com.tinkerpop.gremlin.AbstractGremlinTest;
+import com.tinkerpop.gremlin.LoadGraphWith;
+import com.tinkerpop.gremlin.util.iterator.IteratorUtils;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@AxisRange(min = 0, max = 1)
+@BenchmarkMethodChart(filePrefix = "gremlin-executor")
+@BenchmarkHistoryChart(labelWith = LabelType.CUSTOM_KEY, maxRuns = 20, filePrefix = "hx-gremlin-executor")
+public class GremlinExecutorPerformanceTest extends AbstractGremlinTest  {
+
+    private static final GremlinExecutor gremlinExecutor = GremlinExecutor.build().create();
+
+    @Rule
+    public TestRule benchmarkRun = new BenchmarkRule();
+
+    public final static int DEFAULT_BENCHMARK_ROUNDS = 500;
+    public final static int DEFAULT_WARMUP_ROUNDS = 10;
+
+    @BenchmarkOptions(benchmarkRounds = DEFAULT_BENCHMARK_ROUNDS, warmupRounds = DEFAULT_WARMUP_ROUNDS, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
+    @LoadGraphWith(LoadGraphWith.GraphData.GRATEFUL)
+    @Test
+    public void executorEval() throws Exception {
+        final Map<String, Object> params = new HashMap<>();
+        params.put("g", g);
+
+        final CompletableFuture<Object> future1 = gremlinExecutor.eval("g.V().outE().inV().outE().inV().outE().inV().next(512)", params);
+        final CompletableFuture<Object> future2 = gremlinExecutor.eval("g.V().local(out().out().values(\"name\").fold()).next(7)", params);
+        final CompletableFuture<Object> future3 = gremlinExecutor.eval("g.V().repeat(out()).times(3).next(10)", params);
+        final CompletableFuture<Object> future4 = gremlinExecutor.eval("g.V().repeat(out()).times(2).next(10)", params);
+        final CompletableFuture<Object> future5 = gremlinExecutor.eval("g.V().out().out().out().path().next(1)", params);
+
+        assertEquals(512, IteratorUtils.count(IteratorUtils.convertToIterator(future1.join())));
+        assertEquals(7, IteratorUtils.count(IteratorUtils.convertToIterator(future2.join())));
+        assertEquals(10, IteratorUtils.count(IteratorUtils.convertToIterator(future3.join())));
+        assertEquals(10, IteratorUtils.count(IteratorUtils.convertToIterator(future4.join())));
+        assertEquals(1, IteratorUtils.count(IteratorUtils.convertToIterator(future5.join())));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f6d1444b/tinkergraph-gremlin/src/main/java/com/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/com/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java b/tinkergraph-gremlin/src/main/java/com/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
index 4a74889..2860db2 100644
--- a/tinkergraph-gremlin/src/main/java/com/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
+++ b/tinkergraph-gremlin/src/main/java/com/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
@@ -59,6 +59,7 @@ import java.util.stream.Stream;
 @Graph.OptIn(Graph.OptIn.SUITE_GROOVY_PROCESS_COMPUTER)
 @Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT)
 @Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT_INTEGRATE)
+@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT_PERFORMANCE)
 public class TinkerGraph implements Graph, Graph.Iterators {
 
     static {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f6d1444b/tinkergraph-gremlin/src/test/java/com/tinkerpop/gremlin/tinkergraph/structure/groovy/TinkerGraphGroovyEnvironmentPerformanceTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/com/tinkerpop/gremlin/tinkergraph/structure/groovy/TinkerGraphGroovyEnvironmentPerformanceTest.java b/tinkergraph-gremlin/src/test/java/com/tinkerpop/gremlin/tinkergraph/structure/groovy/TinkerGraphGroovyEnvironmentPerformanceTest.java
new file mode 100644
index 0000000..55998e8
--- /dev/null
+++ b/tinkergraph-gremlin/src/test/java/com/tinkerpop/gremlin/tinkergraph/structure/groovy/TinkerGraphGroovyEnvironmentPerformanceTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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 com.tinkerpop.gremlin.tinkergraph.structure.groovy;
+
+import com.tinkerpop.gremlin.groovy.GroovyEnvironmentPerformanceSuite;
+import com.tinkerpop.gremlin.groovy.loaders.SugarLoader;
+import com.tinkerpop.gremlin.process.ProcessStandardSuite;
+import com.tinkerpop.gremlin.tinkergraph.TinkerGraphGraphProvider;
+import com.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@RunWith(GroovyEnvironmentPerformanceSuite.class)
+@ProcessStandardSuite.GraphProviderClass(provider = TinkerGraphGraphProvider.class, graph = TinkerGraph.class)
+public class TinkerGraphGroovyEnvironmentPerformanceTest {
+    static {
+        SugarLoader.load();
+    }
+}
\ No newline at end of file