Commit 8d0f97a0 authored by Sadrul Habib Chowdhury's avatar Sadrul Habib Chowdhury Committed by Commit Bot

rendering: Add another story for testing throughput.

Add a story to measure throughput that has only main-thread
raf-animations, but no impl-side animations.

BUG=790761

Change-Id: I570c8e3b23c8f8336ae20a82bae2370a52f59453
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1893522
Auto-Submit: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarXida Chen <xidachen@chromium.org>
Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712153}
parent 5e1d08d5
<!doctype html>
<!--
Copyright 2019 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style>
#mainanim {
width: 200px;
height: 200px;
background-color: red;
will-change: transform;
}
</style>
</head>
<body>
<div id='mainanim'></div>
<hr>
<hr>
Press any key to toggle animation.
</body>
<script>
const targetMainFps =
window.location.hash.length > 1 ? +window.location.hash.substr(1) : 0;
const skipEvery = targetMainFps > 0 ? parseInt(60 / targetMainFps) : 0;
var currentValue = 0;
const maxValue = 150;
const valueChange = 5 * skipEvery;
const minValue = 0;
const attributeName = 'transform';
const setProp = (v) => 'translateX(' + v + 'px)';
var animating = false;
var incrementing = false;
var frameCount = 0;
function animateStep() {
if (skipEvery && ++frameCount % skipEvery == 0) {
if (incrementing) {
currentValue += valueChange;
if (currentValue >= maxValue)
incrementing = false;
} else {
currentValue -= valueChange;
if (currentValue <= minValue)
incrementing = true;
}
mainanim.style[attributeName] = setProp(currentValue);
}
if (animating)
requestAnimationFrame(animateStep);
}
function startAnimation() {
animating = true;
requestAnimationFrame(animateStep);
}
function stopAnimation() {
animating = false;
}
function toggle() {
if (animating) {
stopAnimation();
} else {
startAnimation();
}
}
window.onkeypress = toggle;
</script>
</html>
......@@ -36,3 +36,24 @@ class MainSixtyImplSixty(ThroughputMetricStory):
URL = ('file://../../../../chrome/test/data/perf/throughput_test_cases/'
'main-impl-animations-throughput.html#60')
class MainFifteenImplZero(ThroughputMetricStory):
BASE_NAME = 'main_15fps_impl_0fps'
SUPPORTED_PLATFORMS = platforms.ALL_PLATFORMS
URL = ('file://../../../../chrome/test/data/perf/throughput_test_cases/'
'main-animations-throughput.html#15')
class MainThirtyImplZero(ThroughputMetricStory):
BASE_NAME = 'main_30fps_impl_0fps'
SUPPORTED_PLATFORMS = platforms.ALL_PLATFORMS
URL = ('file://../../../../chrome/test/data/perf/throughput_test_cases/'
'main-animations-throughput.html#30')
class MainSixtyImplZero(ThroughputMetricStory):
BASE_NAME = 'main_60fps_impl_0fps'
SUPPORTED_PLATFORMS = platforms.ALL_PLATFORMS
URL = ('file://../../../../chrome/test/data/perf/throughput_test_cases/'
'main-animations-throughput.html#60')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment