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/06/29 13:16:44 UTC

incubator-tinkerpop git commit: Allow script to be passes to profiler utility.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master b2f127e7c -> 87e4e777e


Allow script to be passes to profiler utility.


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

Branch: refs/heads/master
Commit: 87e4e777e79e1374d295cb28db0bb72aa3cc5064
Parents: b2f127e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jun 29 07:14:38 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jun 29 07:14:38 2015 -0400

----------------------------------------------------------------------
 .../gremlin/driver/util/ProfilingApplication.java    | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/87e4e777/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java
index beb6d17..20cc3fd 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java
@@ -48,14 +48,17 @@ public class ProfilingApplication {
     private final Cluster cluster;
     private final int requests;
     private final String executionName;
+    private final String script;
 
     private final ExecutorService executor;
 
-    public ProfilingApplication(final String executionName, final Cluster cluster, final int requests, final ExecutorService executor) {
+    public ProfilingApplication(final String executionName, final Cluster cluster, final int requests, final ExecutorService executor,
+                                final String script) {
         this.executionName = executionName;
         this.cluster = cluster;
         this.requests = requests;
         this.executor = executor;
+        this.script = script;
     }
 
     public long execute() throws Exception {
@@ -69,7 +72,7 @@ public class ProfilingApplication {
 
             final long start = System.nanoTime();
             IntStream.range(0, requests).forEach(i ->
-                client.submitAsync("1+1").thenAcceptAsync(r -> {
+                client.submitAsync(script).thenAcceptAsync(r -> {
                     try {
                         r.all().get(125, TimeUnit.MILLISECONDS);
                     } catch (TimeoutException ex) {
@@ -96,7 +99,7 @@ public class ProfilingApplication {
             ex.printStackTrace();
             throw new RuntimeException(ex);
         } finally {
-            if (client != null) client.close();
+            client.close();
         }
     }
 
@@ -122,6 +125,8 @@ public class ProfilingApplication {
         final int minInProcessPerConnection = Integer.parseInt(options.getOrDefault("minInProcessPerConnection", "16").toString());
         final int workerPoolSize = Integer.parseInt(options.getOrDefault("workerPoolSize", "2").toString());
 
+        final String script = options.getOrDefault("script", "1+1").toString();
+
         final Cluster cluster = Cluster.build(host)
                 .minConnectionPoolSize(minConnectionPoolSize)
                 .maxConnectionPoolSize(maxConnectionPoolSize)
@@ -145,7 +150,7 @@ public class ProfilingApplication {
             final AtomicBoolean meetsRpsExpectation = new AtomicBoolean(true);
             System.out.println("---------------------------WARMUP CYCLE---------------------------");
             for (int ix = 0; ix < warmups && meetsRpsExpectation.get(); ix++) {
-                final long averageRequestsPerSecond = new ProfilingApplication("warmup-" + (ix + 1), cluster, 1000, executor).execute();
+                final long averageRequestsPerSecond = new ProfilingApplication("warmup-" + (ix + 1), cluster, 1000, executor, script).execute();
                 meetsRpsExpectation.set(averageRequestsPerSecond > minExpectedRps);
                 TimeUnit.SECONDS.sleep(1); // pause between executions
             }
@@ -158,7 +163,7 @@ public class ProfilingApplication {
                 final long start = System.nanoTime();
                 System.out.println("----------------------------TEST CYCLE----------------------------");
                 for (int ix = 0; ix < executions && !exceededTimeout.get(); ix++) {
-                    totalRequestsPerSecond += new ProfilingApplication("test-" + (ix + 1), cluster, requests, executor).execute();
+                    totalRequestsPerSecond += new ProfilingApplication("test-" + (ix + 1), cluster, requests, executor, script).execute();
                     exceededTimeout.set((System.nanoTime() - start) > TimeUnit.NANOSECONDS.convert(timeout, TimeUnit.MILLISECONDS));
                     TimeUnit.SECONDS.sleep(1); // pause between executions
                 }