Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Overhead of saving and restoring context state 2.0
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/123.0.0.0 Safari/537.36
Browser:
Chrome 123
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Saving and restoring context state
1628.9 Ops/sec
No Restore
1908.1 Ops/sec
Simple Restore
2152.6 Ops/sec
Simple No restore
3998.0 Ops/sec
HTML Preparation code:
<canvas id="canvas" width="800" height="300"></canvas>
Script Preparation code:
$canvas = document.getElementById('canvas'); $context = $canvas.getContext('2d'); $context.clearRect(0, 0, 800, 300); $iterations = 500;
Tests:
Saving and restoring context state
for (let i=0; i<$iterations; ++i) { $context.save(); $context.fillStyle = 'rgba(100,150,200,0.9)'; $context.fillRect(0, 0, 100, 100); $context.fillRect(50, 20, 50, 50); $context.arc(0, 0, 30, 0, 2 * Math.PI); $context.restore(); }
No Restore
for (let i=0; i<$iterations; ++i) { $context.fillStyle = 'rgba(100,150,200,0.9)'; $context.fillRect(0, 0, 100, 100); $context.fillRect(50, 20, 50, 50); $context.arc(0, 0, 30, 0, 2 * Math.PI); }
Simple Restore
for (let i=0; i<$iterations; ++i) { $context.save(); $context.fillStyle = 'rgba(100,150,200,0.9)'; $context.fillRect(0, 0, 1, 1); $context.restore(); }
Simple No restore
for (let i=0; i<$iterations; ++i) { $context.fillStyle = 'rgba(100,150,200,0.9)'; $context.fillRect(0, 0, 1, 1); }