OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 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 runTest(myCanvas) { |
| 31 invokeToBlobJpg(myCanvas); |
| 32 } |
| 33 |
| 34 window.onload = function () { |
| 35 canvas_idle = createCanvas4k("canvas_idle"); |
| 36 PerfTestRunner.prepareToMeasureValuesAsync({ |
| 37 unit: 'ms', |
| 38 done: function () { |
| 39 isDone = true; |
| 40 }, |
| 41 description: "Measures performance of canvas." |
| 42 }); |
| 43 runTest(canvas_idle); |
| 44 }; |
| 45 </script> |
| 46 </body> |
| 47 </html> |
| 48 |
OLD | NEW |