Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Overhead of saving and restoring context state 3.0
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 18_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.4 Mobile/15E148 Safari/604.1
Browser:
Mobile Safari 18
Operating system:
iOS 18.4.1
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
Not saving and restoring context state
5645.0 Ops/sec
Saving and restoring context state
4596.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:
Not saving and restoring context state
for (let i=0; i<$iterations; ++i) { $context.fillStyle = 'rgba(100,150,200,0.9)'; $context.translate(30, 30); $context.fillRect(0, 0, 100, 100); $context.translate(-30, -30); }
Saving and restoring context state
for (let i=0; i<$iterations; ++i) { $context.save(); $context.fillStyle = 'rgba(100,150,200,0.9)'; $context.translate(30, 30); $context.fillRect(0, 0, 1, 1); $context.restore(); }