Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Sqrt vs Alpha max plus beta min algorithm
(version: 0)
Comparing performance of:
Math.sqrt() vs Alpha max plus beta min
Created:
3 years ago
by:
Guest
Jump to the latest result
Tests:
Math.sqrt()
const RAD_PER_DEG = Math.PI / 180; for(let i = 0; i < 360; i += 0.1) { const r = i * RAD_PER_DEG; const x = Math.sin(r); const y = -Math.cos(r); const s = Math.sqrt(x * x + y * y); }
Alpha max plus beta min
const ALPHA = 0.96043387010342; const BETA = 0.397824734759316; const RAD_PER_DEG = Math.PI / 180; for(let i = 0; i < 360; i += 0.1) { const r = i * RAD_PER_DEG; const x = Math.abs(Math.sin(r)); const y = Math.abs(-Math.cos(r)); const h = x > y ? ALPHA*x + BETA*y : ALPHA*y + BETA*x; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Math.sqrt()
Alpha max plus beta min
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Mobile Safari/537.36
Browser/OS:
Chrome Mobile 132 on Android
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Math.sqrt()
8439.4 Ops/sec
Alpha max plus beta min
13471.1 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the provided benchmark definition and test cases to help explain what's being tested. **Benchmark Definition** The benchmark definition is a JSON object that provides information about the benchmark being created. In this case, it has the following fields: * `Name`: A human-readable name for the benchmark. * `Description`: An optional description of the benchmark (in this case, empty). * `Script Preparation Code`: Optional code to be executed before running the benchmark (empty in this case). * `Html Preparation Code`: Optional HTML code to be used when creating the benchmark page (empty in this case). **Test Cases** The test cases are individual tests that compare different approaches. There are two test cases: 1. **Math.sqrt()** This test case compares the performance of using the built-in `Math.sqrt()` function to calculate the square root of a number. ```javascript const RAD_PER_DEG = Math.PI / 180; for(let i = 0; i < 360; i += 0.1) { const r = i * RAD_PER_DEG; const x = Math.sin(r); const y = -Math.cos(r); const s = Math.sqrt(x * x + y * y); } ``` This test case is likely measuring the performance of calculating the square root of a value in radians. 2. **Alpha max plus beta min** This test case compares the performance of an alternative algorithm for calculating the square root, which involves using alpha and beta values to approximate the square root. ```javascript const ALPHA = 0.96043387010342; const BETA = 0.397824734759316; const RAD_PER_DEG = Math.PI / 180; for(let i = 0; i < 360; i += 0.1) { const r = i * RAD_PER_DEG; const x = Math.abs(Math.sin(r)); const y = Math.abs(-Math.cos(r)); const h = x > y ? ALPHA*x + BETA*y : ALPHA*y + BETA*x; } ``` This test case is likely measuring the performance of this alternative algorithm for calculating the square root. **Library and Special JS Features** There are no libraries explicitly mentioned in the benchmark definition. However, it's worth noting that the `Math` object is used extensively throughout both test cases. One special JS feature being used is the use of template literals (the backticks ``) to define multiline strings. This feature was introduced in ECMAScript 2015 (ES6). **Alternatives** Some alternatives to this benchmarking approach could include: * Using a different testing framework or tool, such as Jest or Mocha. * Adding more test cases to compare other algorithms or approaches for calculating the square root. * Using a different type of data or input to test the performance of these algorithms (e.g., large numbers, complex expressions). * Comparing the performance of these algorithms on different platforms or devices.
Related benchmarks:
Math.sqrt() vs Fast inverse sqrt
Math.sqrt() vs. Binary search sqrt
Sqrt vs Alpha max plus beta min algorithm vs lookup table vs **0.5
Math.pow(x,2) vs Math.sqrt(x)
Comments
Confirm delete:
Do you really want to delete benchmark?