Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
trigetry
(version: 0)
Comparing performance of:
q vs native vs s
Created:
8 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
function sines(x) { if (x < -3.14159265) x += 6.28318531; else if (x > 3.14159265) x -= 6.28318531; if (x < 0) return 1.27323954 * x + .405284735 * x * x; else return 1.27323954 * x - 0.405284735 * x * x; } function coses(x) { x += 1.57079632; if (x > 3.14159265) x -= 6.28318531; if (x < 0) return 1.27323954 * x + 0.405284735 * x * x else return 1.27323954 * x - 0.405284735 * x * x; } function qMafsSin(x) { var sin; if (x < -3.14159265) x += 6.28318531; else if (x > 3.14159265) x -= 6.28318531; if (x < 0) { sin = 1.27323954 * x + .405284735 * x * x; if (sin < 0) sin = .225 * (sin *-sin - sin) + sin; else sin = .225 * (sin * sin - sin) + sin; } else { sin = 1.27323954 * x - 0.405284735 * x * x; if (sin < 0) sin = .225 * (sin *-sin - sin) + sin; else sin = .225 * (sin * sin - sin) + sin; } return sin; } function qMafsCos(x) { var cos; x += 1.57079632; if (x > 3.14159265) x -= 6.28318531; if (x < 0) { cos = 1.27323954 * x + 0.405284735 * x * x; if (cos < 0) cos = .225 * (cos *-cos - cos) + cos; else cos = .225 * (cos * cos - cos) + cos; } else { cos = 1.27323954 * x - 0.405284735 * x * x; if (cos < 0) cos = .225 * (cos *-cos - cos) + cos; else cos = .225 * (cos * cos - cos) + cos; } return cos; }
Tests:
q
sines(10); coses(10);
native
Math.sin(10); Math.cos(10);
s
qMafsSin(10); qMafsCos(10);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
q
native
s
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Browser/OS:
Chrome 127 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
q
3334450.8 Ops/sec
native
1786807.1 Ops/sec
s
3465304.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the provided benchmark JSON and explain what's being tested, compared options, pros and cons of each approach, library usage, special JavaScript features or syntax, and alternative solutions. **Benchmark Definition JSON** The `trigetry` benchmark definition provides two custom functions for sine (`sines`) and cosine (`coses`) calculations, as well as two modified versions of these functions (`qMafsSin` and `qMafsCos`). These functions seem to be designed to test the performance of different approaches for calculating trigonometric values. **Options Compared** The benchmark compares three options: 1. **Native JavaScript** (using `Math.sin` and `Math.cos`) 2. **qMafsSin** (a custom function) 3. **qMafsCos** (another custom function, modified version of qMafsSin) **Pros and Cons of Each Approach** 1. **Native JavaScript**: This approach is likely to be the fastest since it's implemented in the browser's native code. * Pros: Native performance, minimal overhead * Cons: May not be as efficient as hand-optimized code or custom implementations 2. **qMafsSin and qMafsCos**: These custom functions seem to be optimized for a specific use case (likely for a particular library or framework). * Pros: May offer better performance than native JavaScript due to optimization * Cons: Requires understanding the custom implementation, may not be as widely supported 3. **Custom Implementation**: The `sines` and `coses` functions are hand-written and optimized for performance. * Pros: Can potentially outperform both native JavaScript and custom libraries * Cons: Requires manual optimization, testing, and maintenance **Library Usage** The benchmark definition uses a library called `qMaf`, which is not explicitly mentioned in the provided JSON. However, based on the names of the functions, it appears that `qMaf` might be a mathematical library or framework used for trigonometric calculations. **Special JavaScript Features or Syntax** There are no special JavaScript features or syntax mentioned in the benchmark definition. **Alternative Solutions** Other alternative solutions could include: * Using existing libraries like Math.js, mathjs, or other specialized libraries for trigonometric calculations. * Implementing a different custom optimization technique, such as using SIMD instructions (for x86 architectures). * Testing performance on different platforms or devices to compare the results with native JavaScript. In summary, the `trigetry` benchmark compares three options: native JavaScript, two custom functions (`qMafsSin` and `qMafsCos`), and a potential library implementation. The choice of approach depends on the specific use case, performance requirements, and maintenance needs.
Related benchmarks:
pi 180
trigetry
Sqrt vs Alpha max plus beta min algorithm
fast sin cos vs math sin cos
Comments
Confirm delete:
Do you really want to delete benchmark?