add date/time axis option to benchmark
authorDan Vanderkam <danvdk@gmail.com>
Fri, 31 Oct 2014 17:00:17 +0000 (13:00 -0400)
committerDan Vanderkam <danvdk@gmail.com>
Tue, 4 Nov 2014 22:20:16 +0000 (17:20 -0500)
tests/dygraph-many-points-benchmark.html

index 17dadcd..9fc0f81 100644 (file)
         <input type="radio" id="rand" name="group1" value="rand"
           onclick="setDataType(this);"> random points <br></p>
       <p>Timestamps:
-        <input type="radio" id="aligned" name="timestamps" value="aligned"
-          onclick="setTimestampType(this);" checked> aligned
-        <input type="radio" id="unaligned" name="timestamps" value="unaligned"
-          onclick="setTimestampType(this);"> unaligned</p>
+        <input type="radio" id="aligned" name="timestamps" value="aligned" checked> aligned
+        <input type="radio" id="unaligned" name="timestamps" value="unaligned"> unaligned
+      </p>
+      <p>x-axis type:
+        <input type="radio" id="numeric" name="x-axis-type" value="numeric" onclick="setXAxisType(this)" checked> numeric
+        <input type="radio" id="dates" name="x-axis-type" value="date" onclick="setXAxisType(this)"> date/time
       <p>Number of points per series (points):
          <input type="text" id="points" size="20"></p>
       <p>Number of series (series):
       var metrics = null;
       var dataType = "sine";
       var timestamps = "aligned";
+      var numRuns = 0;
 
       var durations = [];
       updatePlot = function() {
         document.getElementById('message').innerHTML = "";
         var plotDiv = document.getElementById('plot');
         plotDiv.innerHTML = 'Redrawing...';
+        var numeric = document.getElementById('numeric').checked;
         var numPoints =
             parseInt(document.getElementById('points').value);
         var numSeries =
@@ -63,8 +67,8 @@
             parseInt(document.getElementById('repetitions').value);
 
         var data = [];
-        var xmin = 0.0;
-        var xmax = 2.0 * Math.PI;
+        var xmin = numeric ? 0.0 : Date.parse("2014/01/01");
+        var xmax = numeric ? 2.0 * Math.PI : Date.parse("2014/12/31");
         var adj = .5;
         var delta = (xmax - xmin) / (numPoints - 1);
         var unalignmentDelta = delta / numSeries;
@@ -90,6 +94,7 @@
               data[i*numSeries + j] = elemCopy;
             }
           }
+          if (!numeric) data[i][0] = new Date(data[i][0]);
         }
         var labels = [ "x" ];
         for (var j = 0; j < numSeries; j++) {
           var start = new Date();
           graph = new Dygraph(plotDiv, data, opts);
           var end = new Date();
-          durations.push([start, end - start]);
+          durations.push([numRuns++, end - start]);
           millisecondss.push(end - start);
         }
         if (repetitions == 1) {
           }
           avg/=millisecondss.length; 
           document.getElementById('message').innerHTML =
-              "Durations: " + millisecondss + " Average: " + avg;
+              "Durations: " + millisecondss + "<br>Average: " + avg;
         }
 
         if (durations.length > 0) {