Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Canvas cache or Path 2D (updated)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:137.0) Gecko/20100101 Firefox/137.0
Browser:
Firefox 137
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Cached canvas
273.4 Ops/sec
Cached Path2D
3163.0 Ops/sec
HTML Preparation code:
<canvas height="500" width="500"/> <canvas height="500" width="500"/>
Script Preparation code:
var [canvas1, canvas2] = Array.from(document.querySelectorAll('canvas')); var ctx1 = canvas1.getContext('2d') var ctx2 = canvas2.getContext('2d') var rects = new Array(100).fill(null).map(() => ({ x: Math.floor(Math.random() * 100), y: Math.floor(Math.random() * 100), width: Math.floor(Math.random() * 100) + 1, height: Math.floor(Math.random() * 100) + 1 }))
Tests:
Cached canvas
for (var rect of rects) { var cached = document.createElement('canvas') cached.width = rect.width cached.height = rect.height rect.cached = cached.getContext('2d') rect.cached.fillStyle = 'blue' rect.cached.fillRect(0, 0, rect.width, rect.height) ctx1.drawImage(rect.cached.canvas, rect.x, rect.y, rect.width, rect.height) } ctx1.clearRect(0, 0, 500, 500) for (var rect of rects) { ctx1.drawImage(rect.cached.canvas, rect.x, rect.y, rect.width, rect.height) }
Cached Path2D
for (var rect of rects) { rect.path = new Path2D() rect.path.rect(rect.x, rect.y, rect.width, rect.height) ctx2.fillStyle = rect.fill ctx2.fill(rect.path) } ctx2.clearRect(0, 0, 500, 500) for (var rect of rects) { ctx2.fillStyle = 'red' ctx2.fill(rect.path) }