Editing Critical canvas size This edit will create a new revision. Your details (optional) Name Email (won’t be displayed; might be used for Gravatar) URL Test case details Title * Published (uncheck if you want to fiddle around before making the page public) Description (in case you feel further explanation is needed)(Markdown syntax is allowed) If the canvas gets bigger than 255x250, the framerate in Firefox (17, Linux) suddenly drops. Above and below that threshold, the framerate is fairly constant and only falls slowly with size. Are you a spammer? (just answer the question) Preparation code Preparation code HTML (this will be inserted in the <body> of a valid HTML5 document in standards mode) (useful when testing DOM operations or including libraries) <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <canvas id="canvas" width="200" height="200" style="border: 1px solid #888"></canvas> Include JavaScript libraries as follows: <script src="//cdn.ext/library.js"></script> Define setup for all tests (variables, functions, arrays or other objects that will be used in the tests) (runs before each clocked test loop, outside of the timed code region) (e.g. define local test variables, reset global variables, clear canvas, etc.) (see FAQ) var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); var start = new Date().getTime(); window.setupCalled = false; // Cross-browser requestAnimationFrame shim window.requestAnimationFrame = (function() { return window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || window.oRequestAnimationFrame; })(); if (ui.benchmarks[0].running) { canvas.width = 255; canvas.height = 240; ctx.fillStyle = "green"; } else if (ui.benchmarks[1].running) { canvas.width = 255; canvas.height = 250; ctx.fillStyle = "blue"; } else if (ui.benchmarks[2].running) { canvas.width = 255; canvas.height = 251; ctx.fillStyle = "orange"; } else if (ui.benchmarks[3].running) { canvas.width = 255; canvas.height = 260; ctx.fillStyle = "violet"; } function isScrolledIntoView(elem) { var docViewTop = $(window).scrollTop(); var docViewBottom = docViewTop + $(window).height(); var elemTop = $(elem).offset().top; var elemBottom = elemTop + $(elem).height(); return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) && (elemBottom <= docViewBottom) && (elemTop >= docViewTop) ); } window.step = function() { if (!isScrolledIntoView(canvas)) { throw "Error: The canvas must be on screen!"; } ctx.clearRect(0, 0, 200, 200); var progress = new Date().getTime() - start; var x = 100 + 20 * Math.cos(progress / 2000 * 2 * Math.PI); var y = 100 - 20 * Math.sin(progress / 2000 * 2 * Math.PI); ctx.beginPath(); ctx.arc(x, y, 10, 0, 2*Math.PI, true); ctx.closePath(); ctx.fill(); window.deferred.resolve(); }; Define teardown for all tests (runs after each clocked test loop, outside of the timed code region) (see FAQ) Code snippets to compare Test 1 Title Async (check if this is an asynchronous test) Code window.deferred = deferred; requestAnimationFrame(step); Test 2 Title Async (check if this is an asynchronous test) Code window.deferred = deferred; requestAnimationFrame(step); Test 3 Title Async (check if this is an asynchronous test) Code window.deferred = deferred; requestAnimationFrame(step); Test 4 Title Async (check if this is an asynchronous test) Code window.deferred = deferred; requestAnimationFrame(step);