4 <script src=
"../resources/runner.js"></script>
7 var canvas2D
= document
.createElement("canvas");
8 var ctx2D
= canvas2D
.getContext("2d");
10 function setSize(width
, height
) {
11 canvas2D
.width
= width
;
12 canvas2D
.height
= height
;
15 function rand(range
) {
16 return Math
.floor(Math
.random() * range
);
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
);
24 function getImageDataFromCanvas2D() {
25 ctx2D
.getImageData(0, 0, canvas2D
.width
, canvas2D
.height
);
29 fillCanvas(ctx2D
, canvas2D
);
31 PerfTestRunner
.measureRunsPerSecond({run
: getImageDataFromCanvas2D
, description
: "This bench test checks the speed on getting ImageData from Canvas2D(1024x1024)."});