Add a Talos test for flooding the main thread with gradient rasterization. (bug 1419306 part 2, r=jmaher)

This commit is contained in:
David Anderson 2017-12-06 01:02:48 -08:00
Родитель 206c236dd9
Коммит 17d9d94075
4 изменённых файлов: 157 добавлений и 1 удалений

Просмотреть файл

@ -47,7 +47,7 @@
"talos_options": ["--disable-stylo"]
},
"g4-e10s": {
"tests": ["basic_compositor_video", "glvideo", "displaylist_mutate", "rasterflood_svg"]
"tests": ["basic_compositor_video", "glvideo", "displaylist_mutate", "rasterflood_svg", "rasterflood_gradient"]
},
"g4-stylo-disabled-e10s": {
"tests": ["basic_compositor_video", "glvideo"],

Просмотреть файл

@ -986,3 +986,26 @@ class rasterflood_svg(PageloaderTest):
'docshell.event_starvation_delay_hint': 1,
'dom.send_after_paint_to_content': False}
unit = 'ms'
@register_test()
class rasterflood_gradient(PageloaderTest):
"""
Test expensive rasterization while the main thread is busy.
"""
tpmanifest = '${talos}/tests/gfx/rasterflood_gradient.manifest'
tpcycles = 1
tppagecycles = 10
tploadnocache = True
tpmozafterpaint = False
tpchrome = False
gecko_profile_interval = 2
gecko_profile_entries = 2000000
win_counters = w7_counters = linux_counters = mac_counters = None
filters = filter.ignore_first.prepare(1) + filter.median.prepare()
"""ASAP mode"""
preferences = {'layout.frame_rate': 0,
'docshell.event_starvation_delay_hint': 1,
'dom.send_after_paint_to_content': False}
lower_is_better = False
unit = 'score'

Просмотреть файл

@ -0,0 +1,132 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Paint-In-Time 2</title>
<style>
.gradient {
position: absolute;
width: 800px;
height: 600px;
opacity: 0.4;
}
</style>
</head>
<body>
<div id="grid">
</div>
</body>
<script>
// Only allow painting a tiny slice of the frame - here, 15ms.
var kFrameBudgetMs = 14;
var kDivCount = 10;
var kMaxTime = 20 * 1000;
var gCrazyCounter = 0;
var gIterations = 0;
var gStart;
var gDivs = [];
function GetColor()
{
var color = GetColor.kColors[GetColor.Index];
GetColor.Index++;
GetColor.Index = (GetColor.Index % GetColor.kColors.length);
return color;
}
GetColor.Index = 0;
GetColor.kColors = ["red", "white", "green", "yellow", "orange", "brown"];
function RadialGradient(offset)
{
this.colors = [GetColor(), GetColor()];
this.percents = [0 + offset, 20 + offset];
this.toStyle = function() {
return "radial-gradient(" +
this.colors[0] + " " + this.percents[0] + "%, " +
this.colors[1] + " " + this.percents[1] + "%)";
};
this.advance = function() {
this.percents[0] += 1;
this.percents[0] %= 80;
this.percents[1] = this.percents[0] + 20;
};
}
function runFrame()
{
var start = performance.now();
// Spin loop.
while (performance.now() - start < kFrameBudgetMs)
gCrazyCounter++;
for (var i = 0; i < gDivs.length; i++) {
var info = gDivs[i];
info.gradient.advance();
info.element.style.background = info.gradient.toStyle();
}
gIterations++;
if (performance.now() - gStart >= kMaxTime) {
if (window.tpRecordTime) {
window.tpRecordTime(gIterations);
}
return;
}
window.requestAnimationFrame(runFrame);
}
function setup()
{
var root = document.getElementById("grid");
for (var i = 0; i < kDivCount; i++) {
var gradient = new RadialGradient(i * 10 / 2);
var div = document.createElement("div");
var info = {
element: div,
gradient: gradient
};
div.classList.add("gradient");
div.style.left = "10px";
div.style.top = "10px";
div.style.background = gradient.toStyle();
root.appendChild(div);
gDivs.push(info);
}
}
function startTest() {
setup();
gStart = performance.now();
window.requestAnimationFrame(runFrame);
}
addEventListener("load", function() {
try {
// Outside of talos, this throws a security exception which no-op this file.
// (It's not required nor allowed for addons since Firefox 17)
// It's used inside talos from non-privileged pages (like during tscroll),
// and it works because talos disables all/most security measures.
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (e) {}
try {
Components.utils.import("resource://gre/modules/Services.jsm");
Services.scriptloader.loadSubScript("chrome://talos-powers-content/content/TalosContentProfiler.js");
TalosContentProfiler.resume("rasterflood_gradient.html loaded", true).then(() => {
startTest();
});
} catch (e) {
startTest();
}
});
</script>
</html>

Просмотреть файл

@ -0,0 +1 @@
% http://localhost/tests/gfx/benchmarks/rasterflood_gradient.html