Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
|
Justin Novosad
2017/01/05 15:41:15
Would be better to land the performance test first
cavalcantii1
2017/01/05 16:16:15
I did thought about that, but do we have an androi
| |
| 2 <html> | |
| 3 <body> | |
| 4 <script src = "../resources/runner.js"></script> | |
| 5 <script> | |
| 6 var canvas_idle = null; | |
| 7 var isDone = false; | |
| 8 | |
| 9 function createCanvas4k(canvas_id) { | |
| 10 var myCanvas = document.createElement("canvas"); | |
| 11 myCanvas.id = canvas_id; | |
| 12 myCanvas.width = 4000; | |
| 13 myCanvas.height = 4000; | |
| 14 myCanvas.getContext("2d").fillStyle = "rgba(0, 255, 0, 0.5)"; | |
| 15 myCanvas.getContext("2d").fillRect(0, 0, myCanvas.width, myCanvas.height); | |
| 16 return myCanvas; | |
| 17 } | |
| 18 | |
| 19 function invokeToBlobJpg(myCanvas) { | |
| 20 var startTime = PerfTestRunner.now(); | |
| 21 myCanvas.toBlob(function(blob){ | |
| 22 PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime); | |
| 23 if (!isDone) { | |
| 24 PerfTestRunner.gc(); | |
| 25 runTest(myCanvas); | |
| 26 } | |
| 27 }, "image/jpeg"); | |
| 28 } | |
| 29 | |
| 30 function draw() { | |
| 31 if (!isDone) | |
| 32 requestAnimationFrame(draw); | |
| 33 } | |
| 34 | |
| 35 function runTest(myCanvas) { | |
| 36 draw(); //repeatedly draw the frame to keep main thread busy | |
|
Justin Novosad
2017/01/05 15:41:15
It is not clear why this is necessary. Won't this
cavalcantii1
2017/01/05 16:16:15
I just based this test on:
https://cs.chromium.org
xlai (Olivia)
2017/01/05 20:13:57
Actually, this test was initially created to compa
| |
| 37 invokeToBlobJpg(myCanvas); | |
| 38 } | |
| 39 | |
| 40 window.onload = function () { | |
| 41 canvas_idle = createCanvas4k("canvas_idle"); | |
| 42 PerfTestRunner.prepareToMeasureValuesAsync({ | |
| 43 unit: 'ms', | |
| 44 done: function () { | |
| 45 isDone = true; | |
| 46 }, | |
| 47 description: "Measures performance of canvas." | |
| 48 }); | |
| 49 runTest(canvas_idle); | |
| 50 }; | |
| 51 </script> | |
| 52 </body> | |
| 53 </html> | |
| 54 | |
| OLD | NEW |