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/13 18:22:06 UTC

incubator-tinkerpop git commit: Move a performance test out of SugarLoaderTest and use standard performance test framework.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master 12d17eed1 -> 4ef0637de


Move a performance test out of SugarLoaderTest and use standard performance test framework.


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

Branch: refs/heads/master
Commit: 4ef0637de950b2c478e1100e763dad71c232b173
Parents: 12d17ee
Author: Stephen Mallette <sp...@apache.org>
Authored: Fri Feb 13 12:21:37 2015 -0500
Committer: Stephen Mallette <sp...@apache.org>
Committed: Fri Feb 13 12:21:37 2015 -0500

----------------------------------------------------------------------
 .../loaders/SugarLoaderPerformanceTest.groovy   | 118 +++++++++++++++++++
 .../groovy/loaders/SugarLoaderTest.groovy       |  60 ----------
 .../GroovyEnvironmentPerformanceSuite.java      |   4 +-
 .../engine/GremlinExecutorPerformanceTest.java  |   1 -
 4 files changed, 121 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4ef0637d/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderPerformanceTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderPerformanceTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderPerformanceTest.groovy
new file mode 100644
index 0000000..3c9b5b0
--- /dev/null
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderPerformanceTest.groovy
@@ -0,0 +1,118 @@
+package org.apache.tinkerpop.gremlin.groovy.loaders
+
+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 org.apache.tinkerpop.gremlin.AbstractGremlinTest
+import org.apache.tinkerpop.gremlin.LoadGraphWith
+import org.junit.FixMethodOrder
+import org.junit.Rule
+import org.junit.Test
+import org.junit.rules.TestRule
+import org.junit.runners.MethodSorters
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@AxisRange(min = 0d, max = 1d)
+@BenchmarkMethodChart(filePrefix = "sugar")
+@BenchmarkHistoryChart(labelWith = LabelType.CUSTOM_KEY, maxRuns = 20, filePrefix = "hx-sugar")
+@FixMethodOrder(MethodSorters.JVM)
+class SugarLoaderPerformanceTest extends AbstractGremlinTest {
+    @Rule
+    public TestRule benchmarkRun = new BenchmarkRule()
+
+    public final static int DEFAULT_BENCHMARK_ROUNDS = 1000
+    public final static int DEFAULT_WARMUP_ROUNDS = 50
+
+    static {
+        SugarLoader.load()
+    }
+
+    @BenchmarkOptions(benchmarkRounds = SugarLoaderPerformanceTest.DEFAULT_BENCHMARK_ROUNDS, warmupRounds = SugarLoaderPerformanceTest.DEFAULT_WARMUP_ROUNDS, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @Test
+    public void java_g_V() throws Exception {
+        g.V().iterate()
+    }
+
+    @BenchmarkOptions(benchmarkRounds = SugarLoaderPerformanceTest.DEFAULT_BENCHMARK_ROUNDS, warmupRounds = SugarLoaderPerformanceTest.DEFAULT_WARMUP_ROUNDS, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @Test
+    public void groovy_g_V() throws Exception {
+        g.V.iterate()
+    }
+
+    @BenchmarkOptions(benchmarkRounds = SugarLoaderPerformanceTest.DEFAULT_BENCHMARK_ROUNDS, warmupRounds = SugarLoaderPerformanceTest.DEFAULT_WARMUP_ROUNDS, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @Test
+    public void java_g_V_outE_inV() throws Exception {
+        g.V().outE().inV().iterate()
+    }
+
+    @BenchmarkOptions(benchmarkRounds = SugarLoaderPerformanceTest.DEFAULT_BENCHMARK_ROUNDS, warmupRounds = SugarLoaderPerformanceTest.DEFAULT_WARMUP_ROUNDS, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @Test
+    public void groovy_g_V_outE_inV() throws Exception {
+        g.V.outE.inV.iterate()
+    }
+
+    @BenchmarkOptions(benchmarkRounds = SugarLoaderPerformanceTest.DEFAULT_BENCHMARK_ROUNDS, warmupRounds = SugarLoaderPerformanceTest.DEFAULT_WARMUP_ROUNDS, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @Test
+    public void java_g_V_outE_inV_outE_inV() throws Exception {
+        g.V().outE().inV().outE().inV().iterate()
+    }
+
+    @BenchmarkOptions(benchmarkRounds = SugarLoaderPerformanceTest.DEFAULT_BENCHMARK_ROUNDS, warmupRounds = SugarLoaderPerformanceTest.DEFAULT_WARMUP_ROUNDS, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @Test
+    public void groovy_g_V_outE_inV_outE_inV() throws Exception {
+        g.V.outE.inV.outE.inV.iterate()
+    }
+
+    @BenchmarkOptions(benchmarkRounds = SugarLoaderPerformanceTest.DEFAULT_BENCHMARK_ROUNDS, warmupRounds = SugarLoaderPerformanceTest.DEFAULT_WARMUP_ROUNDS, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @Test
+    public void java_g_V_name() throws Exception {
+        g.V().values("name").iterate()
+    }
+
+    @BenchmarkOptions(benchmarkRounds = SugarLoaderPerformanceTest.DEFAULT_BENCHMARK_ROUNDS, warmupRounds = SugarLoaderPerformanceTest.DEFAULT_WARMUP_ROUNDS, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @Test
+    public void groovy_g_V_name() throws Exception {
+        g.V.name.iterate()
+    }
+
+    @BenchmarkOptions(benchmarkRounds = SugarLoaderPerformanceTest.DEFAULT_BENCHMARK_ROUNDS, warmupRounds = SugarLoaderPerformanceTest.DEFAULT_WARMUP_ROUNDS, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @Test
+    public void java_g_VX1X_name() throws Exception {
+        g.V(1).values("name").iterate()
+    }
+
+    @BenchmarkOptions(benchmarkRounds = SugarLoaderPerformanceTest.DEFAULT_BENCHMARK_ROUNDS, warmupRounds = SugarLoaderPerformanceTest.DEFAULT_WARMUP_ROUNDS, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @Test
+    public void groovy_g_VX1X_name() throws Exception {
+        g.V(1).name.iterate()
+    }
+
+    @BenchmarkOptions(benchmarkRounds = SugarLoaderPerformanceTest.DEFAULT_BENCHMARK_ROUNDS, warmupRounds = SugarLoaderPerformanceTest.DEFAULT_WARMUP_ROUNDS, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @Test
+    public void java_g_VX1X_outE() throws Exception {
+        g.V(1).outE().iterate()
+    }
+
+    @BenchmarkOptions(benchmarkRounds = SugarLoaderPerformanceTest.DEFAULT_BENCHMARK_ROUNDS, warmupRounds = SugarLoaderPerformanceTest.DEFAULT_WARMUP_ROUNDS, concurrency = BenchmarkOptions.CONCURRENCY_SEQUENTIAL)
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @Test
+    public void groovy_g_VX1X_outE() throws Exception {
+        g.V(1).outE.iterate()
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4ef0637d/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy
index b86fd59..a728e43 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy
@@ -95,64 +95,4 @@ class SugarLoaderTest extends AbstractGremlinTest {
             assertTrue(it[2] instanceof Integer)
         };
     }
-
-    @Test
-    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
-    public void performanceTesting() {
-        SugarLoader.load()
-
-        // warm up
-        clock(5000) { g.V().both.both.both.value("name").iterate() }
-        clock(5000) { g.V().both().both().both().name.iterate() }
-
-        println("g.V")
-        println "  Java8-style:  " + clock(5000) { g.V() }
-        println "  Groovy-style: " + clock(5000) { g.V }
-
-        println("\ng.V.outE.inV")
-        println "  Java8-style:  " + clock(5000) { g.V().outE().inV() }
-        println "  Groovy-style: " + clock(5000) { g.V.outE.inV }
-
-        println("\ng.V.outE.inV.outE.inV")
-        println "  Java8-style:  " + clock(5000) { g.V().outE().inV().outE().inV() }
-        println "  Groovy-style: " + clock(5000) { g.V.outE.inV.outE.inV }
-
-        println("\ng.V.name")
-        println "  Java8-style:  " + clock(5000) { g.V().values('name') }
-        println "  Groovy-style: " + clock(5000) { g.V.name }
-
-        println("\ng.V(1).name")
-        println "  Java8-style:  " + clock(5000) { g.V(1).values('name') }
-        println "  Groovy-style: " + clock(5000) { g.V(1).name }
-
-        /*println("\ng.V(1)['name'] = 'okram'")
-        println "  Java8-style:  " + clock(5000) { g.V(1).property('name', 'okram') }
-        println "  Groovy-style: " + clock(5000) { g.V(1)['name'] = 'okram' }
-
-        println("\ng.V(1).name = 'okram'")
-        println "  Java8-style:  " + clock(5000) { g.V(1).property(single,'name', 'okram') }
-        println "  Groovy-style: " + clock(5000) { g.V(1).name = 'okram' }*/
-
-        println("\ng.V(1).outE")
-        println "  Java8-style:  " + clock(5000) { g.V(1).outE() }
-        println "  Groovy-style: " + clock(5000) { g.V(1).outE }
-
-        println("\ng.V.as('a').map{[it.a.name, it.name]}")
-        println "  Java8-style:  " + clock(5000) {
-            g.V().as('a').map { [it.path('a').value('name'), it.get().value('name')] }
-        }
-        println "  Groovy-style: " + clock(5000) { g.V.as('a').map { [it.a.name, it.name] } }
-
-    }
-
-    def clock = { int loops = 100, Closure closure ->
-        (0..1000).forEach { closure.call() } // warmup
-        (1..loops).collect {
-            def t = System.nanoTime()
-            closure.call()
-            ((System.nanoTime() - t) * 0.000001)
-        }.mean()
-    }
-
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4ef0637d/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentPerformanceSuite.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentPerformanceSuite.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentPerformanceSuite.java
index e167158..ec8fd56 100644
--- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentPerformanceSuite.java
+++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentPerformanceSuite.java
@@ -23,6 +23,7 @@ import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
 import org.apache.tinkerpop.gremlin.GraphManager;
 import org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutorPerformanceTest;
 import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader;
+import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoaderPerformanceTest;
 import org.apache.tinkerpop.gremlin.groovy.util.SugarTestHelper;
 import org.junit.runners.model.InitializationError;
 import org.junit.runners.model.RunnerBuilder;
@@ -38,7 +39,8 @@ import java.util.stream.Stream;
 public class GroovyEnvironmentPerformanceSuite extends AbstractGremlinSuite {
 
     private static final Class<?>[] allTests = new Class<?>[]{
-            GremlinExecutorPerformanceTest.class
+            GremlinExecutorPerformanceTest.class,
+            SugarLoaderPerformanceTest.class
     };
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4ef0637d/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorPerformanceTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorPerformanceTest.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorPerformanceTest.java
index dac9fb5..16f1b77 100644
--- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorPerformanceTest.java
+++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorPerformanceTest.java
@@ -64,7 +64,6 @@ public class GremlinExecutorPerformanceTest extends AbstractGremlinTest  {
     public final static int DEFAULT_BENCHMARK_ROUNDS = 500;
     public final static int DEFAULT_WARMUP_ROUNDS = 10;
 
-
     @Override
     public void setup() throws Exception {
         super.setup();