Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Offscreen canvas vs cached Path2D vs no cache
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:138.0) Gecko/20100101 Firefox/138.0
Browser:
Firefox 138
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Create instances of offscreen canvas
580.4 Ops/sec
Create instances of Path2D
46228.5 Ops/sec
Render offscreen canvases
12318.3 Ops/sec
Render Path2D
17494.0 Ops/sec
Render directly with ctx.fillRect()
17776.2 Ops/sec
HTML Preparation code:
<canvas id="test-canvas"></canvas>
Script Preparation code:
const COUNT = 100 const offscreens = new Array(COUNT) for (let i=0; i<COUNT; i++) { const canvas = document.createElement('canvas') canvas.width = 100 canvas.height = 50 const ctx = canvas.getContext('2d') ctx.fillStyle = "red" ctx.fillRect(0, 0, 100, 50) offscreens[i] = canvas } const path2ds = new Array(COUNT) for (let i=0; i<COUNT; i++) { const path2d = new Path2D() path2d.rect(0, 0, 100, 50) path2ds[i] = path2d } const canvas = document.getElementById('test-canvas') const ctx = canvas.getContext('2d')
Tests:
Create instances of offscreen canvas
const results = new Array(COUNT) for (let i=0; i<COUNT; i++) { const canvas = document.createElement('canvas') canvas.width = 100 canvas.height = 50 const ctx = canvas.getContext('2d') ctx.fillStyle = "red" ctx.fillRect(0, 0, 100, 50) results[i] = canvas }
Create instances of Path2D
const results = new Array(COUNT) for (let i=0; i<COUNT; i++) { const path2d = new Path2D() path2d.rect(0, 0, 100, 50) results[i] = path2d }
Render offscreen canvases
for (let i=0; i<COUNT; i++) { ctx.drawImage(offscreens[i], 0, 0, 100, 50) }
Render Path2D
for (let i=0; i<COUNT; i++) { ctx.fillStyle = "red" ctx.fill(path2ds[i]) }
Render directly with ctx.fillRect()
for (let i=0; i<COUNT; i++) { ctx.fillStyle = "red" ctx.fillRect(0, 0, 100, 50) }