<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[196295] trunk/PerformanceTests</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/196295">196295</a></dd>
<dt>Author</dt> <dd>jonlee@apple.com</dd>
<dt>Date</dt> <dd>2016-02-08 19:30:42 -0800 (Mon, 08 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Tests: refactor and update styles.

* Animometer/tests/resources/main.js: Add helper methods that return
a color that hue rotates based on the date, and a counter value that
increases based on the date. Fix randomInt() to not bias against the min and
max values.

* Animometer/tests/master/resources/canvas-tests.js: Use new helper methods.
* Animometer/tests/master/resources/dom-particles.js: Ditto.
* Animometer/tests/master/resources/particles.js: Ditto.
* Animometer/tests/simple/resources/simple-canvas-paths.js: Refactor to
use a rotating color instead of a random color. The fast switching of color
is too vivid to watch.

* Animometer/tests/bouncing-particles/resources/bouncing-svg-shapes.js:
(BouncingSvgParticlesStage.call.createGradient): Fix the gradient so
that the last stop is located at the end.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkPerformanceTestsAnimometertestsbouncingparticlesresourcesbouncingsvgshapesjs">trunk/PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-svg-shapes.js</a></li>
<li><a href="#trunkPerformanceTestsAnimometertestsmasterresourcescanvastestsjs">trunk/PerformanceTests/Animometer/tests/master/resources/canvas-tests.js</a></li>
<li><a href="#trunkPerformanceTestsAnimometertestsmasterresourcesdomparticlesjs">trunk/PerformanceTests/Animometer/tests/master/resources/dom-particles.js</a></li>
<li><a href="#trunkPerformanceTestsAnimometertestsmasterresourcesparticlesjs">trunk/PerformanceTests/Animometer/tests/master/resources/particles.js</a></li>
<li><a href="#trunkPerformanceTestsAnimometertestsresourcesmainjs">trunk/PerformanceTests/Animometer/tests/resources/main.js</a></li>
<li><a href="#trunkPerformanceTestsAnimometertestssimpleresourcessimplecanvaspathsjs">trunk/PerformanceTests/Animometer/tests/simple/resources/simple-canvas-paths.js</a></li>
<li><a href="#trunkPerformanceTestsChangeLog">trunk/PerformanceTests/ChangeLog</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkPerformanceTestsAnimometertestsbouncingparticlesresourcesbouncingsvgshapesjs"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-svg-shapes.js (196294 => 196295)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-svg-shapes.js        2016-02-09 03:30:38 UTC (rev 196294)
+++ trunk/PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-svg-shapes.js        2016-02-09 03:30:42 UTC (rev 196295)
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx">         var gradient = Utilities.createSVGElement(&quot;linearGradient&quot;, attrs, {}, this._ensureDefsIsCreated());
</span><span class="cx"> 
</span><span class="cx">         for (var i = 0; i &lt; stops; ++i) {
</span><del>-            attrs = { offset: i * 100 / stops + &quot;%&quot;, 'stop-color': Stage.randomColor() };
</del><ins>+            attrs = { offset: i * 100 / (stops - 1) + &quot;%&quot;, 'stop-color': Stage.randomColor() };
</ins><span class="cx">             Utilities.createSVGElement(&quot;stop&quot;, attrs, {}, gradient);
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkPerformanceTestsAnimometertestsmasterresourcescanvastestsjs"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/Animometer/tests/master/resources/canvas-tests.js (196294 => 196295)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/Animometer/tests/master/resources/canvas-tests.js        2016-02-09 03:30:38 UTC (rev 196294)
+++ trunk/PerformanceTests/Animometer/tests/master/resources/canvas-tests.js        2016-02-09 03:30:42 UTC (rev 196295)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">         context.strokeStyle = this._color;
</span><span class="cx">         context.lineWidth = this._lineWidth;
</span><span class="cx"> 
</span><del>-        this._length += Math.sin(Date.now()/100*this._omega);
</del><ins>+        this._length += Math.sin(Stage.dateCounterValue(100) * this._omega);
</ins><span class="cx"> 
</span><span class="cx">         context.beginPath();
</span><span class="cx">         context.moveTo(this._startX, this._startY);
</span></span></pre></div>
<a id="trunkPerformanceTestsAnimometertestsmasterresourcesdomparticlesjs"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/Animometer/tests/master/resources/dom-particles.js (196294 => 196295)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/Animometer/tests/master/resources/dom-particles.js        2016-02-09 03:30:38 UTC (rev 196294)
+++ trunk/PerformanceTests/Animometer/tests/master/resources/dom-particles.js        2016-02-09 03:30:42 UTC (rev 196295)
</span><span class="lines">@@ -14,7 +14,7 @@
</span><span class="cx">         Particle.prototype.reset.call(this);
</span><span class="cx">         this.element.style.width = this.size.x + &quot;px&quot;;
</span><span class="cx">         this.element.style.height = this.size.y + &quot;px&quot;;
</span><del>-        this.element.style.backgroundColor = &quot;hsl(&quot; + ((Date.now()/2000)%1)*360 + &quot;, 70%, 45%)&quot;;
</del><ins>+        this.element.style.backgroundColor = Stage.rotatingColor(2000, .7, .45);
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     move: function()
</span></span></pre></div>
<a id="trunkPerformanceTestsAnimometertestsmasterresourcesparticlesjs"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/Animometer/tests/master/resources/particles.js (196294 => 196295)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/Animometer/tests/master/resources/particles.js        2016-02-09 03:30:38 UTC (rev 196294)
+++ trunk/PerformanceTests/Animometer/tests/master/resources/particles.js        2016-02-09 03:30:42 UTC (rev 196295)
</span><span class="lines">@@ -15,7 +15,7 @@
</span><span class="cx">         this.maxPosition = this.stage.size.subtract(this.size);
</span><span class="cx">         this.position = new Point(this.stage.size.x / 2, this.stage.size.y / 4);
</span><span class="cx"> 
</span><del>-        var angle = Stage.randomInt(0, this.stage.emitSteps) / this.stage.emitSteps * Math.PI * 2 + Date.now()/1000*this.stage.emissionSpin;
</del><ins>+        var angle = Stage.randomInt(0, this.stage.emitSteps) / this.stage.emitSteps * Math.PI * 2 + Stage.dateCounterValue(1000) * this.stage.emissionSpin;
</ins><span class="cx">         this._velocity = new Point(Math.sin(angle), Math.cos(angle))
</span><span class="cx">             .multiply(Stage.random(.8, 1.2));
</span><span class="cx">     },
</span><span class="lines">@@ -87,7 +87,7 @@
</span><span class="cx"> 
</span><span class="cx">     animate: function(timeDelta)
</span><span class="cx">     {
</span><del>-        var offset = (Date.now() / 2000) % 1;
</del><ins>+        var offset = Stage.dateFractionalValue();
</ins><span class="cx">         this.element.style.background = [
</span><span class="cx">             &quot;linear-gradient(&quot;,
</span><span class="cx">             offset * 360,
</span></span></pre></div>
<a id="trunkPerformanceTestsAnimometertestsresourcesmainjs"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/Animometer/tests/resources/main.js (196294 => 196295)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/Animometer/tests/resources/main.js        2016-02-09 03:30:38 UTC (rev 196294)
+++ trunk/PerformanceTests/Animometer/tests/resources/main.js        2016-02-09 03:30:42 UTC (rev 196295)
</span><span class="lines">@@ -269,7 +269,7 @@
</span><span class="cx"> 
</span><span class="cx">     randomInt: function(min, max)
</span><span class="cx">     {
</span><del>-        return Math.round(this.random(min, max));
</del><ins>+        return Math.floor(this.random(min, max + 1));
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     randomPosition: function(maxPosition)
</span><span class="lines">@@ -303,6 +303,26 @@
</span><span class="cx">             + this.randomInt(min, max).toString(16);
</span><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    rotatingColor: function(cycleLengthMs, saturation, lightness)
+    {
+        return &quot;hsl(&quot;
+            + Stage.dateFractionalValue(cycleLengthMs) * 360 + &quot;, &quot;
+            + ((saturation || .8) * 100).toFixed(0) + &quot;%, &quot;
+            + ((lightness || .35) * 100).toFixed(0) + &quot;%)&quot;;
+    },
+
+    // Returns a fractional value that wraps around within [0,1]
+    dateFractionalValue: function(cycleLengthMs)
+    {
+        return (Date.now() / (cycleLengthMs || 2000)) % 1;
+    },
+
+    // Returns an increasing value slowed down by factor
+    dateCounterValue: function(factor)
+    {
+        return Date.now() / factor;
+    },
+
</ins><span class="cx">     randomRotater: function()
</span><span class="cx">     {
</span><span class="cx">         return new Rotater(this.random(1000, 10000));
</span></span></pre></div>
<a id="trunkPerformanceTestsAnimometertestssimpleresourcessimplecanvaspathsjs"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/Animometer/tests/simple/resources/simple-canvas-paths.js (196294 => 196295)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/Animometer/tests/simple/resources/simple-canvas-paths.js        2016-02-09 03:30:38 UTC (rev 196294)
+++ trunk/PerformanceTests/Animometer/tests/simple/resources/simple-canvas-paths.js        2016-02-09 03:30:42 UTC (rev 196295)
</span><span class="lines">@@ -221,7 +221,7 @@
</span><span class="cx">         var context = this.context;
</span><span class="cx">         context.clearRect(0, 0, this.size.x, this.size.y);
</span><span class="cx">         context.lineWidth = Stage.randomInt(1, 20);
</span><del>-        context.strokeStyle = Stage.randomColor();
</del><ins>+        context.strokeStyle = Stage.rotatingColor();
</ins><span class="cx">         context.beginPath();
</span><span class="cx">         context.moveTo(this.size.x / 2, this.size.y / 2);
</span><span class="cx">         this.objects.forEach(function(object) {
</span><span class="lines">@@ -240,7 +240,7 @@
</span><span class="cx">     {
</span><span class="cx">         var context = this.context;
</span><span class="cx">         context.clearRect(0, 0, this.size.x, this.size.y);
</span><del>-        context.fillStyle = Stage.randomColor();
</del><ins>+        context.fillStyle = Stage.rotatingColor();
</ins><span class="cx">         context.beginPath();
</span><span class="cx">         context.moveTo(this.size.x / 2, this.size.y / 2);
</span><span class="cx">         this.objects.forEach(function(object) {
</span></span></pre></div>
<a id="trunkPerformanceTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/ChangeLog (196294 => 196295)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/ChangeLog        2016-02-09 03:30:38 UTC (rev 196294)
+++ trunk/PerformanceTests/ChangeLog        2016-02-09 03:30:42 UTC (rev 196295)
</span><span class="lines">@@ -1,5 +1,25 @@
</span><span class="cx"> 2016-02-07  Jon Lee  &lt;jonlee@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Tests: refactor and update styles.
+
+        * Animometer/tests/resources/main.js: Add helper methods that return
+        a color that hue rotates based on the date, and a counter value that
+        increases based on the date. Fix randomInt() to not bias against the min and
+        max values.
+
+        * Animometer/tests/master/resources/canvas-tests.js: Use new helper methods.
+        * Animometer/tests/master/resources/dom-particles.js: Ditto.
+        * Animometer/tests/master/resources/particles.js: Ditto.
+        * Animometer/tests/simple/resources/simple-canvas-paths.js: Refactor to
+        use a rotating color instead of a random color. The fast switching of color
+        is too vivid to watch.
+
+        * Animometer/tests/bouncing-particles/resources/bouncing-svg-shapes.js:
+        (BouncingSvgParticlesStage.call.createGradient): Fix the gradient so
+        that the last stop is located at the end.
+
+2016-02-07  Jon Lee  &lt;jonlee@apple.com&gt;
+
</ins><span class="cx">         Refactor tune() to not return the complexity of the scene.
</span><span class="cx"> 
</span><span class="cx">         We have stage.complexity() now, so returning the complexity through tune
</span></span></pre>
</div>
</div>

</body>
</html>