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_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Browser:
Chrome 136
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Create instances of offscreen canvas
102.2 Ops/sec
Create instances of Path2D
36666.3 Ops/sec
Render offscreen canvases
10567.3 Ops/sec
Render Path2D
38284.5 Ops/sec
Render directly with ctx.fillRect()
51749.7 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) }