<!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>[194755] 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/194755">194755</a></dd>
<dt>Author</dt> <dd>jonlee@apple.com</dd>
<dt>Date</dt> <dd>2016-01-07 20:28:12 -0800 (Thu, 07 Jan 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Update benchmark test suite
https://bugs.webkit.org/show_bug.cgi?id=152679
Reviewed by Simon Fraser.
Add a new test. The test has a rotating background
gradient, and does a better job physically simulating
particles.
* Animometer/resources/extensions.js: Teach Point to take constants as well as other Points.
(Point.prototype.length): Added.
(Point.prototype.normalize): Added.
* Animometer/resources/runner/tests.js: Add the test to the master suite.
* Animometer/tests/master/particles.html: Added.
* Animometer/tests/master/resources/particles.js: Added. Parent class for different kinds of particles.
(Particle):
(Particle.prototype.reset): If the particle starts slowing down in terms of its animation,
reset it.
(Particle.prototype.animate): Bounce off the walls elastically, and include gravity.
(Particle.prototype.move): Subclasses should override.
(ParticlesStage): Stage includes a rotating gradient background.
* Animometer/tests/master/resources/dom-particles.js: Added. Creates a <div> and adds it to
the stage.
* Animometer/tests/resources/star.svg: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkPerformanceTestsAnimometerresourcesextensionsjs">trunk/PerformanceTests/Animometer/resources/extensions.js</a></li>
<li><a href="#trunkPerformanceTestsAnimometerresourcesrunnertestsjs">trunk/PerformanceTests/Animometer/resources/runner/tests.js</a></li>
<li><a href="#trunkPerformanceTestsChangeLog">trunk/PerformanceTests/ChangeLog</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkPerformanceTestsAnimometertestsmasterparticleshtml">trunk/PerformanceTests/Animometer/tests/master/particles.html</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="#trunkPerformanceTestsAnimometertestsresourcesstarsvg">trunk/PerformanceTests/Animometer/tests/resources/star.svg</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkPerformanceTestsAnimometerresourcesextensionsjs"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/Animometer/resources/extensions.js (194754 => 194755)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/Animometer/resources/extensions.js        2016-01-08 04:08:36 UTC (rev 194754)
+++ trunk/PerformanceTests/Animometer/resources/extensions.js        2016-01-08 04:28:12 UTC (rev 194755)
</span><span class="lines">@@ -92,24 +92,41 @@
</span><span class="cx">
</span><span class="cx"> add: function(other)
</span><span class="cx"> {
</span><ins>+ if(isNaN(other.x))
+ return new Point(this.x + other, this.y + other);
</ins><span class="cx"> return new Point(this.x + other.x, this.y + other.y);
</span><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> subtract: function(other)
</span><span class="cx"> {
</span><ins>+ if(isNaN(other.x))
+ return new Point(this.x - other, this.y - other);
</ins><span class="cx"> return new Point(this.x - other.x, this.y - other.y);
</span><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> multiply: function(other)
</span><span class="cx"> {
</span><ins>+ if(isNaN(other.x))
+ return new Point(this.x * other, this.y * other);
</ins><span class="cx"> return new Point(this.x * other.x, this.y * other.y);
</span><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> move: function(angle, velocity, timeDelta)
</span><span class="cx"> {
</span><span class="cx"> return this.add(Point.pointOnCircle(angle, velocity * (timeDelta / 1000)));
</span><ins>+ },
+
+ length: function() {
+ return Math.sqrt( this.x * this.x + this.y * this.y );
+ },
+
+ normalize: function() {
+ var l = Math.sqrt( this.x * this.x + this.y * this.y );
+ this.x /= l;
+ this.y /= l;
+ return this;
</ins><span class="cx"> }
</span><del>-}
</del><ins>+};
</ins><span class="cx">
</span><span class="cx"> function Insets(top, right, bottom, left)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkPerformanceTestsAnimometerresourcesrunnertestsjs"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/Animometer/resources/runner/tests.js (194754 => 194755)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/Animometer/resources/runner/tests.js        2016-01-08 04:08:36 UTC (rev 194754)
+++ trunk/PerformanceTests/Animometer/resources/runner/tests.js        2016-01-08 04:28:12 UTC (rev 194755)
</span><span class="lines">@@ -24,6 +24,10 @@
</span><span class="cx"> url: "master/canvas-stage.html?pathType=line&lineCap=square",
</span><span class="cx"> name: "Canvas line segments"
</span><span class="cx"> },
</span><ins>+ {
+ url: "master/svg-stage.html",
+ name: "SVG clipped rects"
+ },
</ins><span class="cx"> ]
</span><span class="cx"> ));
</span><span class="cx">
</span></span></pre></div>
<a id="trunkPerformanceTestsAnimometertestsmasterparticleshtml"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/Animometer/tests/master/particles.html (0 => 194755)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/Animometer/tests/master/particles.html         (rev 0)
+++ trunk/PerformanceTests/Animometer/tests/master/particles.html        2016-01-08 04:28:12 UTC (rev 194755)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+ <link rel="stylesheet" type="text/css" href="resources/stage.css">
+ <style>
+ #stage div {
+ position: absolute;
+ -webkit-mask-image: url(../resources/star.svg);
+ mask: url(../resources/star.svg#star-mask);
+ }
+ </style>
+</head>
+<body>
+ <div id="stage"></div>
+ <script src="../../resources/strings.js"></script>
+ <script src="../../resources/extensions.js"></script>
+ <script src="../resources/algorithm.js"></script>
+ <script src="../resources/sampler.js"></script>
+ <script src="../resources/math.js"></script>
+ <script src="../resources/main.js"></script>
+ <script src="resources/particles.js"></script>
+ <script src="resources/svg-particles.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkPerformanceTestsAnimometertestsmasterresourcesdomparticlesjs"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/Animometer/tests/master/resources/dom-particles.js (0 => 194755)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/Animometer/tests/master/resources/dom-particles.js         (rev 0)
+++ trunk/PerformanceTests/Animometer/tests/master/resources/dom-particles.js        2016-01-08 04:28:12 UTC (rev 194755)
</span><span class="lines">@@ -0,0 +1,55 @@
</span><ins>+(function() {
+
+DOMParticle = Utilities.createSubclass(Particle,
+ function(stage)
+ {
+ Particle.call(this, stage);
+ this.element = document.createElement("div");
+ stage.element.appendChild(this.element);
+
+ this._applyAttributes();
+ this.move();
+ }, {
+
+ reset: function()
+ {
+ Particle.prototype.reset.call(this);
+ if (this.element)
+ this._applyAttributes();
+ },
+
+ _applyAttributes: function()
+ {
+ this.element.style.width = this.size.x + "px";
+ this.element.style.height = this.size.y + "px";
+ this.element.style.backgroundColor = "hsl(" + (((Date.now()/2000)%1)*360) + ", 70%, 45%)";
+ },
+
+ move: function()
+ {
+ this.element.style.transform = "translate(" + this.position.x + "px, " + this.position.y + "px)" + this.rotater.rotateZ();
+ }
+});
+
+Utilities.extendObject(ParticlesStage.prototype, {
+ createParticle: function()
+ {
+ return new DOMParticle(this);
+ },
+
+ willRemoveParticle: function(particle)
+ {
+ particle.element.remove();
+ }
+});
+
+ParticlesBenchmark = Utilities.createSubclass(Benchmark,
+ function(options)
+ {
+ Benchmark.call(this, new ParticlesStage(), options);
+ }
+);
+
+window.benchmarkClass = ParticlesBenchmark;
+
+})();
</ins></span></pre></div>
<a id="trunkPerformanceTestsAnimometertestsmasterresourcesparticlesjs"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/Animometer/tests/master/resources/particles.js (0 => 194755)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/Animometer/tests/master/resources/particles.js         (rev 0)
+++ trunk/PerformanceTests/Animometer/tests/master/resources/particles.js        2016-01-08 04:28:12 UTC (rev 194755)
</span><span class="lines">@@ -0,0 +1,133 @@
</span><ins>+function Particle(stage)
+{
+ this.stage = stage;
+ this.rotater = this.stage.randomRotater();
+ this.reset();
+}
+
+Particle.prototype =
+{
+ reset: function()
+ {
+ var randSize = Math.pow(Math.random(), 4) * 25 + 15;
+ this.size = new Point(randSize, randSize);
+ this.maxPosition = this.stage.size.subtract(this.size);
+ this.position = new Point(this.stage.size.x / 2, this.stage.size.y / 4);
+
+ var angle = this.stage.randomInt(0, this.stage.emitSteps) / this.stage.emitSteps * Math.PI * 2 + Date.now()/1000*this.stage.emissionSpin;
+ this._velocity = new Point(Math.sin(angle), Math.cos(angle))
+ .multiply(this.stage.random(.8, 1.2));
+ },
+
+ animate: function(timeDelta)
+ {
+ this.rotater.next(timeDelta);
+
+ this.position = this.position.add(this._velocity.multiply(timeDelta));
+ this._velocity.y += 0.03;
+
+ // If particle is going to move off right side
+ var maxX = this.stage.size.x - this.size.x;
+ if (this.position.x > this.maxPosition.x) {
+ if (this._velocity.x > 0)
+ this._velocity.x *= -1;
+ this.position.x = this.maxPosition.x;
+ } else if (this.position.x < 0) {
+ // If particle is going to move off left side
+ if (this._velocity.x < 0)
+ this._velocity.x *= -1;
+ this.position.x = 0;
+ }
+
+ // If particle is going to move off bottom side
+ if (this.position.y > this.maxPosition.y) {
+ // Adjust direction but maintain magnitude
+ var magnitude = this._velocity.length();
+ this._velocity.x *= 1.5 + .005 * this.size.x;
+ this._velocity = this._velocity.normalize().multiply(magnitude);
+ if (Math.abs(this._velocity.y) < 0.7)
+ this.reset();
+ else {
+ if (this._velocity.y > 0)
+ this._velocity.y *= -0.999;
+ this.position.y = this.maxPosition.y;
+ }
+ } else if (this.position.y < 0) {
+ // If particle is going to move off top side
+ var magnitude = this._velocity.length();
+ this._velocity.x *= 1.5 + .005 * this.size.x;
+ this._velocity = this._velocity.normalize().multiply(magnitude);
+ if (this._velocity.y < 0)
+ this._velocity.y *= -0.998;
+ this.position.y = 0;
+ }
+
+ this.move();
+ },
+
+ move: function()
+ {
+ }
+}
+
+ParticlesStage = Utilities.createSubclass(Stage,
+ function()
+ {
+ Stage.call(this);
+ this.particles = [];
+ }, {
+
+ initialize: function(benchmark)
+ {
+ Stage.prototype.initialize.call(this, benchmark);
+ this.emissionSpin = this.random(0, 3);
+ this.emitSteps = this.randomInt(4, 6);
+ },
+
+ animate: function(timeDelta)
+ {
+ var offset = (Date.now() / 2000) % 1;
+ this.element.style.background = [
+ "linear-gradient(",
+ offset * 360,
+ "deg, hsl(",
+ offset * 360,
+ ", 50%, 80%), hsl(",
+ (offset + .1) * 360,
+ ", 50%, 80%))"
+ ].join("");
+
+ timeDelta /= 4;
+ this.particles.forEach(function(particle) {
+ particle.animate(timeDelta);
+ });
+ },
+
+ tune: function(count)
+ {
+ if (count == 0)
+ return this.particles.length;
+
+ if (count > 0) {
+ for (var i = 0; i < count; ++i)
+ this.particles.push(this.createParticle());
+ return this.particles.length;
+ }
+
+ count = Math.min(-count, this.particles.length);
+
+ if (typeof(this.willRemoveParticle) == "function") {
+ for (var i = 0; i < count; ++i)
+ this.willRemoveParticle(this.particles[i]);
+ }
+
+ this.particles.splice(0, count);
+ return this.particles.length;
+ },
+
+ complexity: function()
+ {
+ // We add one to represent the gradient background.
+ return this.particles.length + 1;
+ }
+});
</ins></span></pre></div>
<a id="trunkPerformanceTestsAnimometertestsresourcesstarsvg"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/Animometer/tests/resources/star.svg (0 => 194755)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/Animometer/tests/resources/star.svg         (rev 0)
+++ trunk/PerformanceTests/Animometer/tests/resources/star.svg        2016-01-08 04:28:12 UTC (rev 194755)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 1 1">
+ <defs>
+ <mask id="star-mask" maskUnits="objectBoundingBox" maskContentUnits="objectBoundingBox">
+ <path fill="white" d="M.50,0L.38,.38L0,.38L.30,.60L.18,1L.50,.75L.82,1L.70,.60L1,.38L.62,.38z" />
+ </mask>
+ </defs>
+ <path d="M.50,0L.38,.38L0,.38L.30,.60L.18,1L.50,.75L.82,1L.70,.60L1,.38L.62,.38z" fill="white" />
+</svg>
</ins></span></pre></div>
<a id="trunkPerformanceTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/ChangeLog (194754 => 194755)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/ChangeLog        2016-01-08 04:08:36 UTC (rev 194754)
+++ trunk/PerformanceTests/ChangeLog        2016-01-08 04:28:12 UTC (rev 194755)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2016-01-07 Jon Lee <jonlee@apple.com>
+
+ Update benchmark test suite
+ https://bugs.webkit.org/show_bug.cgi?id=152679
+
+ Reviewed by Simon Fraser.
+
+ Add a new test. The test has a rotating background
+ gradient, and does a better job physically simulating
+ particles.
+
+ * Animometer/resources/extensions.js: Teach Point to take constants as well as other Points.
+ (Point.prototype.length): Added.
+ (Point.prototype.normalize): Added.
+ * Animometer/resources/runner/tests.js: Add the test to the master suite.
+ * Animometer/tests/master/particles.html: Added.
+ * Animometer/tests/master/resources/particles.js: Added. Parent class for different kinds of particles.
+ (Particle):
+ (Particle.prototype.reset): If the particle starts slowing down in terms of its animation,
+ reset it.
+ (Particle.prototype.animate): Bounce off the walls elastically, and include gravity.
+ (Particle.prototype.move): Subclasses should override.
+ (ParticlesStage): Stage includes a rotating gradient background.
+ * Animometer/tests/master/resources/dom-particles.js: Added. Creates a <div> and adds it to
+ the stage.
+ * Animometer/tests/resources/star.svg: Added.
+
</ins><span class="cx"> 2016-01-03 Jon Lee <jonlee@apple.com>
</span><span class="cx">
</span><span class="cx"> Update benchmark test suite
</span></span></pre>
</div>
</div>
</body>
</html>