Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Measure texts - OffscreenCanvas vs Canvas
(version: 0)
Comparing performance of:
Canvas vs OffscreenCanvas
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var canvas = document.createElement('canvas'); var context = canvas.getContext('2d'); context.font = 'bold 48px serif'; var offscreenCanvas = new OffscreenCanvas(0, 0); var offscreenContext = offscreenCanvas.getContext('2d'); offscreenContext.font = 'bold 48px serif';
Tests:
Canvas
context.measureText("TESTM").width
OffscreenCanvas
offscreenContext.measureText("TESTM").width
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Canvas
OffscreenCanvas
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
3 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Browser/OS:
Chrome 144 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Canvas
1156754.2 Ops/sec
OffscreenCanvas
1334942.2 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark test cases. **What is being tested?** The test case measures the performance of two rendering methods: 1. **Canvas**: The traditional 2D canvas element, which renders text and other graphics directly on the screen using hardware acceleration. 2. **OffscreenCanvas**: An alternative to Canvas that allows rendering text and other graphics off-screen, without actually displaying them on the screen. This approach can be beneficial for situations where fast rendering is necessary, such as in games or animations. **Options compared** The test case compares two options: 1. **Canvas**: Uses the traditional 2D canvas element. * Pros: Fast rendering, well-established API, and widely supported by browsers. * Cons: Requires hardware acceleration, which can be a bottleneck on low-end devices or in situations where fast rendering is not necessary. 2. **OffscreenCanvas**: Uses an off-screen canvas element to render text. * Pros: Can provide faster rendering times, as the text is not actually displayed on the screen until it's needed. * Cons: May require additional setup and handling for text rendering, as it needs to be manually copied or manipulated to display the rendered text. **Library used** Neither of the test cases uses a specific JavaScript library for rendering. Instead, they rely on the built-in `OffscreenCanvas` API (in Chrome) or the traditional 2D canvas element (in other browsers). **Special JS feature or syntax** The test case utilizes the new `OffscreenCanvas` API, which is a relatively recent addition to the Web API (introduced in Chrome 83). This API allows for faster rendering by bypassing the browser's rendering pipeline. **Other considerations** When choosing between Canvas and OffscreenCanvas, consider the following factors: * **Rendering speed**: If fast rendering is critical, OffscreenCanvas might be a better choice. However, if rendering performance is not a top priority, Canvas might be sufficient. * **Browser support**: Canvas is widely supported by modern browsers, while OffscreenCanvas is only available in Chrome and some other browsers that have implemented the API. * **Text rendering**: If text rendering is a bottleneck or requires special handling, OffscreenCanvas might provide an advantage. However, if text rendering is straightforward and not a concern, Canvas might be a better choice. **Alternative approaches** Other alternatives to consider: 1. ** WebGL**: A low-level, graphics-intensive API that can provide fast rendering for complex graphics and animations. 2. **WebAssembly**: A binary format that allows for compilation of languages like C and Rust into efficient, platform-agnostic code, which can be used for performance-critical rendering tasks. Keep in mind that these alternatives might require more expertise and setup than Canvas or OffscreenCanvas, but they can offer even faster rendering performance at the cost of increased complexity.
Related benchmarks:
OffscreenCanvas measureText
setFont measureText OffscreenCanvas vs Canvas
Measure text
OffsetScreenCanvas.measureText VS. Canvas.measureText
Comments
Confirm delete:
Do you really want to delete benchmark?