Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Canvas test
(version: 0)
test
Comparing performance of:
fillRect vs clearRect
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<canvas id="canvas"></canvas>
Tests:
fillRect
var ctx = document.getElementById('canvas').getContext('2d'); ctx.fillRect(0, 0, 500, 500);
clearRect
var ctx = document.getElementById('canvas').getContext('2d'); ctx.clearRect(0, 0, 500, 500)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
fillRect
clearRect
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:138.0) Gecko/20100101 Firefox/138.0
Browser/OS:
Firefox 138 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
fillRect
112509.1 Ops/sec
clearRect
1638178.4 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of MeasureThat.net and explore what's being tested in this benchmark. **What is being tested?** The provided JSON represents two individual test cases, each measuring the performance of a specific JavaScript function: `fillRect` and `clearRect`. The `fillRect` function draws a rectangle on a 2D context using the HTML5 `<canvas>` element, while `clearRect` clears a rectangular area within the same context. **Options being compared** The two test cases differ in their approach to drawing or clearing the rectangle: 1. **fillRect**: This test case creates a new 2D context for each execution and draws a full-rectangle using the `fillRect` method. 2. **clearRect**: In contrast, this test case also creates a new 2D context but uses the `clearRect` method to clear a smaller rectangular area within that context. **Pros and Cons of each approach:** * **fillRect**: + Pros: - Simulates real-world usage of drawing rectangles. - Encourages proper use of contexts and methods for efficient rendering. + Cons: - Creates an extra context object, which might lead to unnecessary memory allocation and garbage collection. - May not accurately represent the actual performance difference between `fillRect` and `clearRect`. * **clearRect**: + Pros: - Reduces memory overhead by reusing contexts for both drawing and clearing. - Potentially more accurate representation of real-world usage, as it simulates clearing a smaller rectangular area within an existing context. + Cons: - May not accurately represent the performance difference between `fillRect` and `clearRect`, as the clearing process is often less computationally intensive. **Library and its purpose** In this benchmark, no libraries are explicitly mentioned. However, it's worth noting that MeasureThat.net might use some internal libraries or frameworks for rendering, caching, or other optimization techniques to enhance performance measurement accuracy. **Special JS feature or syntax (not applicable in this case)** No special JavaScript features or syntax are being tested in this benchmark. The focus is on the simple drawing and clearing operations using the `fillRect` and `clearRect` methods. **Alternative approaches** If you were interested in exploring alternative benchmarks, here are a few ideas: * Measure the performance of different rendering engines (e.g., WebGL vs. Canvas). * Compare the performance of various algorithms for calculating bounding rectangles or clipping paths. * Investigate the impact of caching or memoization on benchmark results. Keep in mind that these alternatives would likely require significant changes to the existing benchmark structure and might introduce additional complexity.
Related benchmarks:
save/restore vs manual - shadow
rgb vs rgba (1 & 0.5) vs hex canvas
save/restore vs manual
save&restore vs manual
Translucent RGBa vs Opaque RGBa with global alpha
Comments
Confirm delete:
Do you really want to delete benchmark?