Allow adding any number of markers to the graph. The markers can be labeled
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Feb 2016 03:30:23 +0000 (03:30 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Feb 2016 03:30:23 +0000 (03:30 +0000)
and contain timestamp and sample index data. Make it a part of the controller
rather than keeping it in the sampler.

* Animometer/resources/debug-runner/animometer.css: Add styles for markers
* Animometer/resources/debug-runner/graph.js: Create the markers and add
text labels.
* Animometer/resources/runner/animometer.js: Assume the samplingTimeOffset
is just one of the marks provided.
* Animometer/resources/strings.js: Add Strings.json.marks.
* Animometer/tests/resources/main.js:
(Controller): Keep marks here. They are keyed by the marker name, so no two
markers should have the same name.
(recordFirstSample): Refactor to use mark.
(mark): Allows for arbitrary data if needed later. The timestamp maintained
is relative to the absolute start timestamp.
(containsMark): Checks whether a mark with a specific comment exists.
(processSamples): Removes the _startTimestamp offset from the marks before
setting it in results.
* Animometer/tests/resources/sampler.js: Remove marks.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196290 268f45cc-cd09-0410-ab3c-d52691b4dbfc

PerformanceTests/Animometer/resources/debug-runner/animometer.css
PerformanceTests/Animometer/resources/debug-runner/graph.js
PerformanceTests/Animometer/resources/runner/animometer.js
PerformanceTests/Animometer/resources/strings.js
PerformanceTests/Animometer/tests/resources/main.js
PerformanceTests/Animometer/tests/resources/sampler.js
PerformanceTests/ChangeLog

index 1f0317d..18fb94e 100644 (file)
@@ -403,10 +403,14 @@ label.tree-label {
     shape-rendering: crispEdges;
 }
 
-.sample-time {
+.marker line {
     stroke: #5493D6;
 }
 
+.marker text {
+    fill: #999;
+}
+
 .left-mean {
     stroke: #7ADD49;
     opacity: .8;
index e518563..c33ae2a 100644 (file)
@@ -85,13 +85,26 @@ Utilities.extendObject(window.benchmarkController, {
                 .style("text-anchor", "end")
                 .text(axes[1]);
 
-        // samplingTimeOffset
-        svg.append("line")
-            .attr("x1", x(graphData.samplingTimeOffset))
-            .attr("x2", x(graphData.samplingTimeOffset))
-            .attr("y1", yLeft(0))
-            .attr("y2", yLeft(yAxisLeft.scale().domain()[1]))
-            .attr("class", "sample-time marker");
+        // marks
+        var yMin = yLeft(0);
+        var yMax = yLeft(yAxisLeft.scale().domain()[1]);
+        for (var markName in graphData.marks) {
+            var mark = graphData.marks[markName];
+            var xLocation = x(mark.time);
+
+            var markerGroup = svg.append("g")
+                .attr("class", "marker")
+                .attr("transform", "translate(" + xLocation + ", 0)");
+            markerGroup.append("text")
+                    .attr("transform", "translate(10, " + (yMin - 10) + ") rotate(-90)")
+                    .style("text-anchor", "start")
+                    .text(markName)
+            markerGroup.append("line")
+                    .attr("x1", 0)
+                    .attr("x2", 0)
+                    .attr("y1", yMin)
+                    .attr("y2", yMax);
+        }
 
         // left-mean
         svg.append("line")
@@ -124,8 +137,8 @@ Utilities.extendObject(window.benchmarkController, {
         cursorGroup.append("line")
             .attr("x1", 0)
             .attr("x2", 0)
-            .attr("y1", yLeft(0))
-            .attr("y2", yLeft(0));
+            .attr("y1", yMin)
+            .attr("y2", yMin);
 
         // Data
         var allData = graphData.samples;
index 1f291bd..1b49a50 100644 (file)
@@ -126,7 +126,7 @@ ResultsTable = Utilities.createClass(
                     testResults[Strings.json.experiments.frameRate][Strings.json.measurements.average]
                 ],
                 samples: data,
-                samplingTimeOffset: testResults[Strings.json.samplingTimeOffset]
+                marks: testResults[Strings.json.marks]
             }
             if (testResults[Strings.json.targetFPS])
                 graphData.targetFPS = testResults[Strings.json.targetFPS];
index c53d6e1..e8ad5e9 100644 (file)
@@ -25,6 +25,7 @@ var Strings = {
     json: {
         score: "score",
         samples: "samples",
+        marks: "marks",
 
         targetFPS: "targetFPS",
         samplingTimeOffset: "samplingTimeOffset",
index a405f63..7cf5942 100644 (file)
@@ -8,6 +8,7 @@ Controller = Utilities.createClass(
         // Default data series: timestamp, complexity, estimatedFrameLength
         this._sampler = new Sampler(options["series-count"] || 3, 60 * testLength, this);
         this._estimator = new SimpleKalmanEstimator(options["kalman-process-error"], options["kalman-measurement-error"]);
+        this._marks = {};
 
         this.initialComplexity = 0;
     }, {
@@ -22,7 +23,18 @@ Controller = Utilities.createClass(
     recordFirstSample: function(stage, startTimestamp)
     {
         this._sampler.record(startTimestamp, stage.complexity(), -1);
-        this._sampler.mark(Strings.json.samplingTimeOffset, { time: 0 });
+        this.mark(Strings.json.samplingTimeOffset, startTimestamp);
+    },
+
+    mark: function(comment, timestamp, data) {
+        data = data || {};
+        data.time = timestamp;
+        data.index = this._sampler.sampleCount;
+        this._marks[comment] = data;
+    },
+
+    containsMark: function(comment) {
+        return comment in this._marks;
     },
 
     update: function(stage, timestamp)
@@ -49,12 +61,16 @@ Controller = Utilities.createClass(
         var samples = this._sampler.samples;
 
         var samplingIndex = 0;
-        var samplingMark = this._sampler.marks[Strings.json.samplingTimeOffset];
+        var samplingMark = this._marks[Strings.json.samplingTimeOffset];
         if (samplingMark) {
             samplingIndex = samplingMark.index;
             results[Strings.json.samplingTimeOffset] = samplingMark.time;
         }
 
+        for (var markName in this._marks)
+            this._marks[markName].time -= this._startTimestamp;
+        results[Strings.json.marks] = this._marks;
+
         results[Strings.json.samples] = samples[0].map(function(timestamp, i) {
             var result = {
                 // Represent time in seconds
@@ -140,9 +156,7 @@ AdaptiveController = Utilities.createSubclass(Controller,
     {
         if (!this._startedSampling && timestamp > this._samplingTimestamp) {
             this._startedSampling = true;
-            this._sampler.mark(Strings.json.samplingTimeOffset, {
-                time: this._samplingTimestamp - this._startTimestamp
-            });
+            this.mark(Strings.json.samplingTimeOffset, this._samplingTimestamp);
         }
 
         // Start the work for the next frame.
index e60995f..2d7d0b9 100644 (file)
@@ -62,7 +62,6 @@ Sampler = Utilities.createClass(
             this.samples[i] = array;
         }
         this.sampleCount = 0;
-        this.marks = {};
     }, {
 
     record: function() {
@@ -73,14 +72,6 @@ Sampler = Utilities.createClass(
         ++this.sampleCount;
     },
 
-    mark: function(comment, data) {
-        data = data || {};
-        // The mark exists after the last recorded sample
-        data.index = this.sampleCount;
-
-        this.marks[comment] = data;
-    },
-
     process: function()
     {
         var results = {};
index fef8a52..aea3447 100644 (file)
@@ -1,5 +1,28 @@
 2016-02-07  Jon Lee  <jonlee@apple.com>
 
+        Allow adding any number of markers to the graph. The markers can be labeled
+        and contain timestamp and sample index data. Make it a part of the controller
+        rather than keeping it in the sampler.
+
+        * Animometer/resources/debug-runner/animometer.css: Add styles for markers
+        * Animometer/resources/debug-runner/graph.js: Create the markers and add
+        text labels.
+        * Animometer/resources/runner/animometer.js: Assume the samplingTimeOffset
+        is just one of the marks provided.
+        * Animometer/resources/strings.js: Add Strings.json.marks.
+        * Animometer/tests/resources/main.js:
+        (Controller): Keep marks here. They are keyed by the marker name, so no two
+        markers should have the same name.
+        (recordFirstSample): Refactor to use mark.
+        (mark): Allows for arbitrary data if needed later. The timestamp maintained
+        is relative to the absolute start timestamp.
+        (containsMark): Checks whether a mark with a specific comment exists.
+        (processSamples): Removes the _startTimestamp offset from the marks before
+        setting it in results.
+        * Animometer/tests/resources/sampler.js: Remove marks.
+
+2016-02-07  Jon Lee  <jonlee@apple.com>
+
         Get rid of options member variable in Benchmark.
 
         Options are only needed when initializing the stage or benchmark, so there's no