haikuwebkit/PerformanceTests/Animation/balls.html

239 lines
8.1 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
Copyright (c) 2012 Cameron Adams. All rights reserved.
Copyright (c) 2012 Code Aurora Forum. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Code Aurora Forum, Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This test is based on code written by Cameron Adams and imported from
http://themaninblue.com/experiment/AnimationBenchmark/html
-->
<head>
<title>Benchmark - HTML &amp; JavaScript</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="author" content="The Man in Blue" />
<meta name="robots" content="all" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<style type="text/css">
html {
height: 100%;
}
body {
width: 100%;
height: 100%;
overflow: hidden;
margin: 0;
padding: 0;
}
span {
position: absolute;
width: 12px;
height: 12px;
overflow: hidden;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
background-color: #000000;
}
.shadows span {
-webkit-box-shadow: 4px 4px 3px rgba(0,0,0,0.33);
-moz-box-shadow: 4px 4px 3px rgba(0,0,0,0.33);
box-shadow: 4px 4px 3px rgba(0,0,0,0.33);
}
#frameRate {
position: absolute;
right: 10px;
bottom: 10px;
z-index: 100;
font-size: 25px;
font-family: Arial, Helvetica, sans-serif;
}
</style>
<script type="text/javascript">
var FRAMES_PER_TIMER_READING = 10;
var MAX_PARTICLES = 2500;
var MAX_VELOCITY = 50;
var PARTICLE_RADIUS = 6;
var STAGE_WIDTH = 600;
var STAGE_HEIGHT = 600;
var COLORS = ["#cc0000", "#ffcc00", "#aaff00", "#0099cc", "#194c99", "#661999"];
var frameTimes = [];
var iteration = 0;
var run = 0;
var animateIntervalId = 0;
var statistics = [];
var frameRates = [];
var particles = [];
window.onload = function () {
Some perf. tests have variances that differ greatly between runs https://bugs.webkit.org/show_bug.cgi?id=97510 Reviewed by Benjamin Poulain. PerformanceTests: In order to control the number of iterations and processes to use from run-perf-tests, always use 20 iterations on all tests except Dromaeo, where even doing 5 iterations is prohibitively slow, by default. Without this change, it'll become extremely hard for us to tweak the number of iterations and processes to use from run-perf-tests. * Animation/balls.html: * DOM/DOMTable.html: * DOM/resources/dom-perf.js: (runBenchmarkSuite.PerfTestRunner.measureTime): * Dromaeo/resources/dromaeorunner.js: * Layout/floats_100_100.html: * Layout/floats_100_100_nested.html: * Layout/floats_20_100.html: * Layout/floats_20_100_nested.html: * Layout/floats_2_100.html: * Layout/floats_2_100_nested.html: * Layout/floats_50_100.html: * Layout/floats_50_100_nested.html: * Layout/subtree-detaching.html: * Parser/html5-full-render.html: * SVG/SvgHitTesting.html: * resources/runner.js: * resources/results-template.html: Tools: Use multiple instances of DumpRenderTree or WebKitTestRunner to amortize the effect of the runtime environment on test results (we run each instance after one another, not in parallel). We use 4 instances of the test runner, each executing 5 in-process iterations, for the total of 20 iterations as it was done previously in single process. These values are hard-coded in perftest.py and runner.js but they are to be configurable in the future. Set of 5 iterations obtained by the same test runner is treated as an "iteration group" and each metric now reports an array of the length 4 with each element containing an array of 5 iteration values obtained by each test runner instance as opposed to a flattened array of 20 iteration values. Unfortunately, we can use the same trick on Dromaeo because we're already doing only 5 iterations and repeating the entire Dromaeo 4 times will take too long. We need to disable more Dromaeo tests as needed. To this end, added SingleProcessPerfTest to preserve the old behavior. * Scripts/webkitpy/performance_tests/perftest.py: (PerfTestMetric.append_group): Renamed from append. (PerfTestMetric.grouped_iteration_values): Added. (PerfTestMetric.flattened_iteration_values): Renamed from iteration_values. (PerfTest.__init__): Takes the number of processes (drivers) to run tests with. This parameter is only used by SingleProcessPerfTest. (PerfTest.run): Repeat tests using different driver processes. (PerfTest._run_with_driver): Returns a boolean instead of a list of measured metrics since metrics are shared between multiple drivers (i.e. multiple calls to _run_with_driver). We instead use _ensure_metrics to obtain the matched metrics and store the data there. (PerfTest._ensure_metrics): Added. (SingleProcessPerfTest): Added. Used to run Dromaeo tests where running it on 4 different instances of DumpRenderTree/WebKitTestRunner takes too long. (SingleProcessPerfTest.__init__): (ReplayPerfTest._run_with_driver): Updated to use _ensure_metrics. (PerfTestFactory): Use SingleProcessPerfTest to run Dromaeo tests. * Scripts/webkitpy/performance_tests/perftest_unittest.py: Updated various tests that expect _run_with_driver to return a list of metrics. Now it returns a boolean indicating whether the test succeeded or not. Obtain the dictionary of metrics via test._metrics instead. (TestPerfTestMetric.test_append): Updated per name and added some test cases for grouped_iteration_values. (TestPerfTest._assert_results_are_correct): (TestSingleProcessPerfTest): Added. (TestSingleProcessPerfTest.test_use_only_one_process): (TestSingleProcessPerfTest.test_use_only_one_process.run_single): (TestReplayPerfTest.test_run_with_driver_accumulates_results): (TestReplayPerfTest.test_run_with_driver_accumulates_memory_results): * Scripts/webkitpy/performance_tests/perftestsrunner_integrationtest.py: Updated values of sample standard deviations since we're now running tests 4 times. (MainTest._test_run_with_json_output.mock_upload_json): (MainTest.test_run_with_upload_json_should_generate_perf_webkit_json): LayoutTests: Use dromaeoIterationCount now that we no longer support iterationCount. * fast/harness/perftests/runs-per-second-iterations.html: Canonical link: https://commits.webkit.org/129631@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144583 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-03-03 23:19:31 +00:00
PerfTestRunner.prepareToMeasureValuesAsync({done: onCompletedRun, unit: 'fps'});
// Create the particles
for (var i = 0; i < MAX_PARTICLES; i++)
particles.push(new Particle());
// Start the animation
animateIntervalId = setInterval(animate, 1);
}
function animate()
{
var currTime = PerfTestRunner.now();
var timeDelta = currTime - frameTimes[frameTimes.length - 1];
if (isNaN(timeDelta))
timeDelta = 0;
// Draw each particle
for (var particle in particles)
particles[particle].draw(timeDelta);
if ((iteration++ % FRAMES_PER_TIMER_READING) == 0) {
// Limit the frame time array to the last 30 frames
if (frameTimes.length > 30)
frameTimes.splice(0, 1);
frameTimes.push(currTime);
// Calculate the framerate based upon the difference between the absolute times of the oldest and newest frames, subdivided by how many frames were drawn inbetween
var frameRate = document.getElementById("frameRate");
var frameRateVal = FRAMES_PER_TIMER_READING * 1000 / ((currTime - frameTimes[0]) / (frameTimes.length - 1));
if (!isNaN(frameRateVal))
PerformanceTests: Dromaeo should report individual test result https://bugs.webkit.org/show_bug.cgi?id=99800 Reviewed by Eric Seidel. Made one small modification to Droameo's webrunner.js so that it reports individual runs/s values for each subtest. This allows us to compute the aggregated run/s for each iteration like other performance tests. Also stop measuring memory usage in Dromaeo tests because some Dromaeo tests (e.g. jslib-modify-jquery) have unrealistic memory usage, and measuring them at the time of teardown doesn't make much sense. * Animation/balls.html: Fixed typo: measureValueAync. * Dromaeo/resources/dromaeo/web/webrunner.js: * Dromaeo/resources/dromaeorunner.js: (DRT.setup): Call prepareToMeasureValuesAsync so that DRT.teardown can use meausreValueAsync, and log "Running 5 times". Since the log container will be inserted before iframe, we need to explicitly insert the iframe as the first child of the body element to avoid logs from affecting the iframe's position. Also specify the number of iterations by calling PerfTestRunner.iterationCount() so that we may adjust the number of iterations in PerfTestRunner. (DRT.progress): Log individual measurement for each subtest. (DRT.teardown): Compute the aggregated result for each iteration, and log them using measureValueAsync. * resources/runner.js: (PerfTestRunner.logStatistics): Merged printStatistics since it's no longer needed after r131638. (PerfTestRunner): Removed getAndPrintMemoryStatistics since it was used only in Dromaeo tests but we no longer measure memory usage in Dromaeo tests. (start): Increment completedRuns from -1 to 0 for Dromaeo tests where we don't want to ignore the initial measurement. Note that ignoreWarmUpAndLog ignores the measurements for which completedRuns is negative. (ignoreWarmUpAndLog): We don't measure memory usage in Dromaeo tests. See above. (PerfTestRunner.iterationCount): Added. This abstraction allows us to auto-adjust the number of iterations from run-perf-tests in near future. (PerfTestRunner.measureValueAsync): Renamed from measureValueAync. Tools: Dromaeo should report individual test result https://bugs.webkit.org/show_bug.cgi?id=99800 Reviewed by Eric Seidel. Ignore subtest results spit out by Dromaeo tests. * Scripts/webkitpy/performance_tests/perftest.py: (PerfTest): Added a line to ignore. * Scripts/webkitpy/performance_tests/perftest_unittest.py: (MainTest.test_parse_output_with_subtests): Added. LayoutTests: Fix a test and re-enable fast/harness/perftests on Chromium. * fast/harness/perftests/runs-per-second-log.html: * platform/chromium/TestExpectations: Canonical link: https://commits.webkit.org/122080@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@136492 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-12-04 10:00:54 +00:00
PerfTestRunner.measureValueAsync(frameRateVal);
}
}
function Particle()
{
var angle = Math.PI * 2 * PerfTestRunner.random();
var velocity = MAX_VELOCITY / 8 * 7 * PerfTestRunner.random() + MAX_VELOCITY / 8;
var x = STAGE_WIDTH / 2 - PARTICLE_RADIUS;
var y = STAGE_HEIGHT / 2 - PARTICLE_RADIUS;
// Create visual element for the particle
var domNode = document.createElement('span');
document.body.appendChild(domNode);
// Set initial position to middle of screen
domNode.style.left = x + "px";
domNode.style.top = y + "px";
// Set colour of element
domNode.style.backgroundColor = COLORS[Math.floor(Math.random() * COLORS.length)];
function destroy()
{
document.body.removeChild(domNode);
return;
}
function draw(timeDelta)
{
// Calculate next position of particle
var nextX = x + Math.cos(angle) * velocity * (timeDelta / 1000);
var nextY = y + Math.sin(angle) * velocity * (timeDelta / 1000);
// If particle is going to move off right side of screen
if (nextX + PARTICLE_RADIUS * 2 > STAGE_WIDTH)
// If angle is between 3 o'clock and 6 o'clock
if ((angle >= 0 && angle < Math.PI / 2))
angle = Math.PI - angle;
// If angle is between 12 o'clock and 3 o'clock
else if (angle > Math.PI / 2 * 3)
angle = angle - (angle - Math.PI / 2 * 3) * 2
// If particle is going to move off left side of screen
if (nextX < 0)
// If angle is between 6 o'clock and 9 o'clock
if ((angle > Math.PI / 2 && angle < Math.PI))
angle = Math.PI - angle;
// If angle is between 9 o'clock and 12 o'clock
else if (angle > Math.PI && angle < Math.PI / 2 * 3)
angle = angle + (Math.PI / 2 * 3 - angle) * 2
// If particle is going to move off bottom side of screen
if (nextY + PARTICLE_RADIUS * 2 > STAGE_HEIGHT)
// If angle is between 3 o'clock and 9 o'clock
if ((angle > 0 && angle < Math.PI))
angle = Math.PI * 2 - angle;
// If particle is going to move off top side of screen
if (nextY < 0)
// If angle is between 9 o'clock and 3 o'clock
if ((angle > Math.PI && angle < Math.PI * 2))
angle = angle - (angle - Math.PI) * 2;
domNode.style.left = nextX + "px";
domNode.style.top = nextY + "px";
x = nextX;
y = nextY;
}
return { draw: draw, destroy: destroy }
}
function onCompletedRun() {
clearInterval(animateIntervalId);
for (var particle in particles) {
var p = particles[particle];
particles[particle] = 0;
p.destroy();
}
particles = [];
frameRate.innerHTML = "";
}
</script>
<script src="../resources/runner.js"></script>
</head>
<body>
<div id="frameRate">
</div>
</body>
</html>