OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <body> |
| 4 <script src="../resources/runner.js"></script> |
| 5 <script> |
| 6 var imgHeight = 1024; |
| 7 var imgWidth = 1024; |
| 8 var canvas = document.createElement("canvas"); |
| 9 canvas.width = imgWidth; |
| 10 canvas.height = imgHeight; |
| 11 var context = canvas.getContext('2d'); |
| 12 var image = context.createImageData(imgWidth, imgHeight); |
| 13 |
| 14 function rand(range) { |
| 15 return Math.floor(Math.random() * range); |
| 16 } |
| 17 |
| 18 function initializeImageData() { |
| 19 for(var i = 0; i < image.data.length; i++) |
| 20 image.data[i] = rand(256); |
| 21 } |
| 22 |
| 23 function imageBitmapFromImageData() { |
| 24 /*The return Promise is not retained because this test |
| 25 is meant to only measure the immediate run time of |
| 26 createImageBitmap from an ImageData, which is known |
| 27 to be implemented in a way that does all the work |
| 28 synchronously, even though the API is technically async.*/ |
| 29 createImageBitmap(image, 0, 0, imgWidth, imgHeight); |
| 30 } |
| 31 |
| 32 initializeImageData(); |
| 33 PerfTestRunner.measureRunsPerSecond({run: imageBitmapFromImageData, description:
"This bench test checks the speed on creating ImageBitmap from ImageData(1024x1
024)."}); |
| 34 </script> |
| 35 </body> |
| 36 </html> |
OLD | NEW |