1 <!DOCTYPE html> 2 <html> 3 <body> 4 <script src="../resources/runner.js"></script> 5 <script> 6 7 var canvas2D = document.createElement("canvas"); 8 var ctx2D = canvas2D.getContext("2d"); 9 10 function setSize(width, height) { 11 canvas2D.width = width; 12 canvas2D.height = height; 13 } 14 15 function rand(range) { 16 return Math.floor(Math.random() * range); 17 } 18 19 function fillCanvas(ctx2d, canvas2d) { 20 ctx2d.fillStyle = "rgba(" + rand(255) + "," + rand(255) + "," + rand(255) + "," + rand(255) + ")"; 21 ctx2d.fillRect(0, 0, canvas2d.width, canvas2d.height); 22 } 23 24 function getImageDataFromCanvas2D() { 25 ctx2D.getImageData(0, 0, canvas2D.width, canvas2D.height); 26 } 27 28 setSize(1024, 1024); 29 fillCanvas(ctx2D, canvas2D); 30 31 PerfTestRunner.measureRunsPerSecond({run: getImageDataFromCanvas2D, description: "This bench test checks the speed on getting ImageData from Canvas2D(1024x1024)."}); 32 33 </script> 34 </body> 35 </html> 36