Chromium Code Reviews| Index: third_party/WebKit/PerformanceTests/Canvas/toBlob_duration_jpeg.html |
| diff --git a/third_party/WebKit/PerformanceTests/Canvas/toBlob_duration_jpeg.html b/third_party/WebKit/PerformanceTests/Canvas/toBlob_duration_jpeg.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..92fdc75985c1aaca6e92b31c4aef1caf46f9ecee |
| --- /dev/null |
| +++ b/third_party/WebKit/PerformanceTests/Canvas/toBlob_duration_jpeg.html |
| @@ -0,0 +1,54 @@ |
| +<!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
|
| +<html> |
| +<body> |
| +<script src = "../resources/runner.js"></script> |
| +<script> |
| +var canvas_idle = null; |
| +var isDone = false; |
| + |
| +function createCanvas4k(canvas_id) { |
| + var myCanvas = document.createElement("canvas"); |
| + myCanvas.id = canvas_id; |
| + myCanvas.width = 4000; |
| + myCanvas.height = 4000; |
| + myCanvas.getContext("2d").fillStyle = "rgba(0, 255, 0, 0.5)"; |
| + myCanvas.getContext("2d").fillRect(0, 0, myCanvas.width, myCanvas.height); |
| + return myCanvas; |
| +} |
| + |
| +function invokeToBlobJpg(myCanvas) { |
| + var startTime = PerfTestRunner.now(); |
| + myCanvas.toBlob(function(blob){ |
| + PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime); |
| + if (!isDone) { |
| + PerfTestRunner.gc(); |
| + runTest(myCanvas); |
| + } |
| + }, "image/jpeg"); |
| +} |
| + |
| +function draw() { |
| + if (!isDone) |
| + requestAnimationFrame(draw); |
| +} |
| + |
| +function runTest(myCanvas) { |
| + 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
|
| + invokeToBlobJpg(myCanvas); |
| +} |
| + |
| +window.onload = function () { |
| + canvas_idle = createCanvas4k("canvas_idle"); |
| + PerfTestRunner.prepareToMeasureValuesAsync({ |
| + unit: 'ms', |
| + done: function () { |
| + isDone = true; |
| + }, |
| + description: "Measures performance of canvas." |
| + }); |
| + runTest(canvas_idle); |
| +}; |
| +</script> |
| +</body> |
| +</html> |
| + |