Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Unified Diff: PerformanceTests/Canvas/upload-webgl-to-texture.html

Issue 200253002: Make canvas perf tests run less than 6 sec. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Introduce canvas_runner.js to remove duplicated code. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « PerformanceTests/Canvas/upload-canvas-2d-to-texture.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PerformanceTests/Canvas/upload-webgl-to-texture.html
diff --git a/PerformanceTests/Canvas/upload-webgl-to-texture.html b/PerformanceTests/Canvas/upload-webgl-to-texture.html
index 59bbbfd02bb0c857c0c845cb662d9329f7fad683..e8781edcce0d1230cdf93df0651c57d1709e38f0 100644
--- a/PerformanceTests/Canvas/upload-webgl-to-texture.html
+++ b/PerformanceTests/Canvas/upload-webgl-to-texture.html
@@ -2,6 +2,7 @@
<html>
<body>
<script src="../resources/runner.js"></script>
+<script src="resources/canvas_runner.js"></script>
<script>
var sourceCanvas3D = document.createElement('canvas');
@@ -9,10 +10,8 @@ var sourceCtx = sourceCanvas3D.getContext('experimental-webgl');
var destCanvas3D = document.createElement('canvas');
var destCtx = destCanvas3D.getContext('experimental-webgl');
if (!sourceCtx || !destCtx)
- PerfTestRunner.logFatalError("\nWebGL is not supported or enabled on this platform!\n");
-var MEASURE_DRAW_TIMES = 100;
-var MAX_COUNT = 60000;
-var count = 0;
+ CanvasRunner.logFatalError("\nWebGL is not supported or enabled on this platform!\n");
+var tex = null;
function setSize(width, height) {
sourceCanvas3D.width = width;
@@ -34,35 +33,32 @@ function renderWebGL(gl) {
gl.clear(gl.COLOR_BUFFER_BIT);
}
-function uploadWebGLToWebGLTexture() {
- var tex = destCtx.createTexture();
+function preRun() {
+ tex = destCtx.createTexture();
destCtx.bindTexture(destCtx.TEXTURE_2D, tex);
+}
- var start = PerfTestRunner.now();
+function doRun() {
+ destCtx.texImage2D(destCtx.TEXTURE_2D, 0, destCtx.RGBA, destCtx.RGBA, destCtx.UNSIGNED_BYTE, sourceCanvas3D);
+}
- for (var i = 0; i < MEASURE_DRAW_TIMES; i++) {
- destCtx.texImage2D(destCtx.TEXTURE_2D, 0, destCtx.RGBA, destCtx.RGBA, destCtx.UNSIGNED_BYTE, sourceCanvas3D);
- }
+function ensureComplete() {
destCtx.readPixels(0, 0, 1, 1, sourceCtx.RGBA, sourceCtx.UNSIGNED_BYTE, new Uint8Array(4));
- destCtx.deleteTexture(tex);
- count++;
-
- var elapsedTime = PerfTestRunner.now() - start;
- PerfTestRunner.measureValueAsync(MEASURE_DRAW_TIMES * 1000 / elapsedTime);
- if (count < MAX_COUNT)
- requestAnimationFrame(uploadWebGLToWebGLTexture);
}
-function onCompletedRun() {
- count = MAX_COUNT;
+function postRun() {
+ destCtx.deleteTexture(tex);
}
window.onload = function () {
- PerfTestRunner.prepareToMeasureValuesAsync({done: onCompletedRun, unit: 'runs/s',
- description: "This benchmark checks the speed on uploading WebGL(1024x1024) to WebGL Texture(1024x1024)."});
setSize(1024, 1024);
renderWebGL(sourceCtx);
- uploadWebGLToWebGLTexture();
+ CanvasRunner.start({
+ description: "This benchmark checks the speed on uploading WebGL(1024x1024) to WebGL Texture(1024x1024).",
+ preRun: preRun,
+ doRun: doRun,
+ ensureComplete: ensureComplete,
+ postRun: postRun});
}
</script>
« no previous file with comments | « PerformanceTests/Canvas/upload-canvas-2d-to-texture.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698