devicemap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From re...@apache.org
Subject svn commit: r1693783 - /devicemap/trunk/clients/2.0/reference/src/Main.java
Date Sun, 02 Aug 2015 00:33:19 GMT
Author: rezan
Date: Sun Aug  2 00:33:19 2015
New Revision: 1693783

URL: http://svn.apache.org/r1693783
Log:
warmup time

Modified:
    devicemap/trunk/clients/2.0/reference/src/Main.java

Modified: devicemap/trunk/clients/2.0/reference/src/Main.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/2.0/reference/src/Main.java?rev=1693783&r1=1693782&r2=1693783&view=diff
==============================================================================
--- devicemap/trunk/clients/2.0/reference/src/Main.java (original)
+++ devicemap/trunk/clients/2.0/reference/src/Main.java Sun Aug  2 00:33:19 2015
@@ -38,7 +38,7 @@ public class Main {
     String testString = null;
 
     boolean failure = false;
-    int warmup = 0;
+    int warmup_sec = 0;
 
     long start, time;
 
@@ -59,7 +59,7 @@ public class Main {
       } else if(!option.startsWith("-") && testString == null) {
         testString = option;
       } else if(option.equals("-w")) {
-        warmup = 15;
+        warmup_sec = 3;
       } else if(option.equals("-q")) {
         verbose = -1;
       } else if(option.equals("-v")) {
@@ -79,8 +79,8 @@ public class Main {
 
     //WARMUP
     
-    if(warmup > 0) {
-      runWarmup(warmup, patterns, attributes, tests);
+    if(warmup_sec > 0) {
+      runWarmup(warmup_sec, patterns, attributes, tests);
     }
 
     //BUILD THE DEVICEMAP CLIENT
@@ -263,13 +263,17 @@ public class Main {
     return testCount != passCount;
   }
 
-  public static void runWarmup(int iterations, List<String> p, List<String> a,
List<String> t) throws Exception {
-    log("Warmup...", -1);
+  public static void runWarmup(int secs, List<String> p, List<String> a, List<String>
t) throws Exception {
+    log("Warmup " + secs + " sec(s)...", -1);
 
     int origVerbose = verbose;
     verbose = -2;
 
-    for(int i = 0; i < iterations; i++) {
+    long start = System.nanoTime();
+    long runtime = 0;
+    long iterations = 0;
+
+    while(runtime < ((long)secs * 1000 * 1000 * 1000)) {
       DeviceMapClient client = new DeviceMapClient();
 
       for(String pattern : p) {
@@ -283,6 +287,10 @@ public class Main {
       for(String test : t) {
         test(client, new JsonFile(test));
       }
+
+      iterations++;
+
+      runtime = System.nanoTime() - start;
     }
 
     System.gc();
@@ -290,7 +298,7 @@ public class Main {
 
     verbose = origVerbose;
 
-    log("Warmup completed", -1);
+    log("Warmup completed, " + iterations + " iteration(s)", -1);
   }
 
   public static String getTime(long ns)



Mime
View raw message