Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: tools/perf/page_sets/tough_animation_cases/css_animations_many_keyframes.html

Issue 665833002: Add CSS Animations performance tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <meta name="viewport" content="width=device-width, user-scalable=no"> 2 <meta name="viewport" content="width=device-width, user-scalable=no">
3 <link rel="stylesheet" type="text/css" href="resources/tablet.css"> 3 <link rel="stylesheet" type="text/css" href="resources/tablet.css">
4 <script src="resources/perftesthelper.js"></script> 4 <script src="resources/perftesthelper.js"></script>
5 <script src="resources/web_animations_api_check.js"></script>
6 <style> 5 <style>
7 target { 6 target {
8 position: absolute; 7 position: absolute;
9 width: 0px; 8 width: 0px;
10 height: 0px; 9 height: 0px;
11 border: 5px solid green; 10 border: 5px solid green;
12 border-radius: 100%; 11 border-radius: 100%;
13 } 12 }
14 </style> 13 </style>
15 14
16 <container id="container"></container> 15 <container id="container"></container>
17 16
18 <script> 17 <script>
19 var N = PerfTestHelper.getN(1000); 18 var N = PerfTestHelper.getN(1000);
20 var numKeyframes = 500; 19 var numKeyframes = 500;
21 var duration = 4000; 20 var duration = 4000;
22 21
23 function makeKeyframes(numKeyframes, width, height) { 22 function makeKeyframes(numKeyframes, width, height) {
24 var keyframes = []; 23 var keyframes = '@-webkit-keyframes anim {\n'
25 for (var i = 0; i < numKeyframes + 1; i++) { 24 for (var i = 0; i < numKeyframes + 1; i++) {
26 var fraction = i / numKeyframes; 25 var fraction = i / numKeyframes;
27 var t = fraction * 2 * Math.PI; 26 var t = fraction * 2 * Math.PI;
28 var x = Math.cos(t) - Math.pow(Math.cos(4 * t), 3); 27 var x = Math.cos(t) - Math.pow(Math.cos(4 * t), 3);
29 x = ((x / 4 + 1 / 2) * width).toFixed(5); 28 x = ((x / 4 + 1 / 2) * width).toFixed(5);
30 var y = Math.pow(Math.sin(4 * t), 3) - Math.sin(2 * t); 29 var y = Math.pow(Math.sin(4 * t), 3) - Math.sin(2 * t);
31 y = ((y / 4 + 1 / 2) * height).toFixed(5); 30 y = ((y / 4 + 1 / 2) * height).toFixed(5);
32 keyframes.push({transform: 'translate(' + x + 'px, ' + y + 'px)'}); 31 keyframes += (fraction * 100) + '% { transform: translate(' + x + 'px, ' + y + 'px); }\n';
33 } 32 }
34 return keyframes; 33 return keyframes;
35 } 34 }
36 35
37 requestAnimationFrame(function() { 36 var style = document.createElement('style');
38 var keyframes = makeKeyframes(numKeyframes, 550, 800); 37 style.textContent = makeKeyframes(numKeyframes, 550, 800);
39 for (var i = 0; i < N; i++) { 38
40 var target = document.createElement('target'); 39 for (var i = 0; i < N; i++) {
41 container.appendChild(target); 40 var target = document.createElement('target');
42 target.animate(keyframes, {duration: duration, iterations: Infinity, delay: -duration / 10 * i / N}); 41 target.style.webkitAnimation = 'anim ' + duration + 'ms linear infinite ' + (- duration / 10 * i / N) + 'ms';
43 } 42 container.appendChild(target);
44 }); 43 }
44
45 container.appendChild(style);
45 46
46 PerfTestHelper.signalReady(); 47 PerfTestHelper.signalReady();
47 </script> 48 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698