Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
canvasperf
(version: 0)
Comparing performance of:
float vs int
Created:
8 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<canvas id="canvas" width="400" height="400"></canvas>
Script Preparation code:
var canvas = document.getElementById('canvas'); var ctx = canvas.getContext("2d");
Tests:
float
ctx.beginPath(); ctx.fillStyle = '#000'; ctx.arc(70.5 + Math.random(), 70.5 + Math.random(), 6, 0, Math.PI * 2, true); ctx.fill();
int
ctx.beginPath(); ctx.fillStyle = '#000'; ctx.arc(50, 50, 6, 0, Math.PI * 2, true); ctx.fill();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
float
int
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
11 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Browser/OS:
Chrome 136 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
float
1343789.5 Ops/sec
int
1286373.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of JavaScript microbenchmarks on MeasureThat.net. **Benchmark Overview** The provided JSON represents a benchmark for measuring the performance of JavaScript engines in rendering graphics using the 2D context of an HTML canvas element. The benchmark consists of two individual test cases: "float" and "int", which differ in how they specify the radius of a circle to be drawn on the canvas. **Script Preparation Code** The script preparation code is used to initialize the JavaScript environment before running the benchmark. In this case, it sets up a canvas element with an ID of "canvas" and gets a reference to its 2D context using `document.getElementById('canvas')` and `getContext("2d")`, respectively. **Html Preparation Code** The HTML preparation code is used to create the HTML structure that will be rendered by the JavaScript engine. In this case, it creates an empty canvas element with a width of 400 pixels and a height of 400 pixels. **Test Cases** There are two individual test cases: 1. **"float"`**: This test case uses `Math.random()` to generate a random radius between 0 and 10 for the circle to be drawn on the canvas. The circle is filled with black (`#000`) using `ctx.fillStyle` and then rendered. 2. **"int"`**: This test case explicitly specifies the radius of the circle as an integer value (6) using `ctx.arc(50, 50, 6, 0, Math.PI * 2, true)`. **Comparison of Options** In this benchmark, two options are being compared: * Using a random radius (`Math.random()`) vs. specifying an explicit integer radius. * This comparison highlights the performance differences between using arbitrary-precision arithmetic (with `Math.random()`) versus fixed-precision arithmetic (with an explicit integer value). **Pros and Cons** Pros of using `Math.random()`: * Allows for dynamic and unpredictable test cases, which can be useful in measuring engine performance under various conditions. * Can provide more accurate results for engines that handle arbitrary-precision arithmetic well. Cons of using `Math.random()`: * May result in slower execution times due to the overhead of generating random numbers. * May not provide a fair comparison if the engine is optimized for integer arithmetic. Pros of specifying an explicit integer radius: * Provides a predictable and consistent test case, which can be useful in measuring engine performance under specific conditions. * Can result in faster execution times since the engine only needs to perform fixed-precision arithmetic. Cons of specifying an explicit integer radius: * May not provide accurate results if the engine is optimized for arbitrary-precision arithmetic or has issues with precision handling. **Library and Purpose** There are no external libraries mentioned in this benchmark. The Canvas API is used directly, which is a built-in JavaScript API for rendering 2D graphics on HTML5 canvases. **Special JS Features or Syntax** None of the provided test cases use special JavaScript features or syntax that require explanation. **Other Alternatives** MeasureThat.net provides several other alternatives for comparing JavaScript engine performance, including: * Measuring CPU execution times using benchmarking libraries like Benchmark.js. * Using microbenchmarks specifically designed for testing web browser performance, such as the WebPageTest benchmark suite. * Utilizing existing benchmarking frameworks and tools, such as V8 Profiler (for Google Chrome) or SpiderMonkey Profiler (for Mozilla Firefox).
Related benchmarks:
rgb vs rgba vs hex canvas
rgb vs rgba vs hex canvas
rgb vs rgba (1 & 0.5) vs hex canvas
RGB vs RGBa vs HSL vs Hex using Canvas v2
RGB vs RGBa vs HSL vs Hex using Canvas with alpha = false
Comments
Confirm delete:
Do you really want to delete benchmark?