Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Canvas cache or Path 2D
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/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Cached canvas
51.3 Ops/sec
Cached Path2D
11458.1 Ops/sec
HTML Preparation code:
<canvas/>
Script Preparation code:
var canvas = document.querySelector('canvas'); var ctx = canvas.getContext('2d') var rects = new Array(100).fill({ x: 100, y: 100, width: 100, height: 100, fill: 'blue' })
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 = rect.fill rect.cached.fillRect(0, 0, rect.width, rect.height) ctx.drawImage(rect.cached.canvas, rect.x, rect.y, rect.width, rect.height) } for (var rect of rects) { ctx.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(0, 0, rect.width, rect.height) ctx.fillStyle = rect.fill ctx.fill(rect.path) } for (var rect of rects) { ctx.fillStyle = rect.fill ctx.fill(rect.path) }