Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Mathjs evaluation
(version: 0)
Comparing performance of:
Native vs Mathjs compile
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/12.2.0/math.min.js"></script>
Script Preparation code:
var func1 = (x, y, z) => x*x + y*y + z*z; var expr2 = math.parse('x^2 + y^2 + z^2').compile() var func2 = (x, y, z) => expr2.evaluate({x, y, z})
Tests:
Native
const out = [] for (let x = 0; x < 100; x += 1) { for (let y = 0; y < 100; y += 1) { for (let z = 0; z < 100; z += 1) { out.push(func1(x, y, z)) } } }
Mathjs compile
const out = [] for (let x = 0; x < 100; x += 1) { for (let y = 0; y < 100; y += 1) { for (let z = 0; z < 100; z += 1) { out.push(func2(x, y, z)) } } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Native
Mathjs compile
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_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Browser/OS:
Chrome 135 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Native
176.8 Ops/sec
Mathjs compile
5.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Benchmark Overview** MeasureThat.net is a platform that allows users to create and run JavaScript microbenchmarks. The provided benchmark measures the performance of two approaches: native (without any library or compilation) and Mathjs-compiled (using the Mathjs library). **Native Approach** The native approach tests the execution speed of the `func1` function, which is a simple polynomial expression evaluated using basic arithmetic operations. **Pros and Cons:** * Pros: + Simple to implement and understand. + No additional dependencies or compilation required. * Cons: + May not be as efficient as other approaches due to the overhead of JavaScript's interpreter and engine. **Mathjs-Compiled Approach** The Mathjs-compiled approach uses the Mathjs library to compile the expression into a native machine code, which is then executed. * Pros: + Can be faster than the native approach due to compilation. + Provides better performance for complex expressions. * Cons: + Requires an additional dependency (Mathjs) and compilation step. + May introduce overhead due to library initialization and runtime checks. **Mathjs Library** The Mathjs library is a JavaScript implementation of mathematical functions, allowing developers to compile expressions into native machine code using the Just-In-Time (JIT) compiler. The library provides various benefits, including: * Faster execution speeds for complex calculations. * Reduced memory usage due to efficient data representation and caching. * Simplified development and debugging with built-in utilities. **Special JavaScript Feature:** This benchmark does not utilize any special JavaScript features or syntax that may impact performance, such as async/await, promises, or modern web APIs. **Other Alternatives:** Other alternatives for benchmarking JavaScript performance include: 1. **Babel**: A transpiler that converts ES6+ code to older JavaScript versions. 2. **V8.js**: A JavaScript engine that provides a similar API to the V8 engine used by Google Chrome. 3. **SpiderMonkey**: A JavaScript engine developed by Mozilla, often used in benchmarking and performance testing. 4. **Emscripten**: A compiler that translates C/C++ code to WebAssembly (WASM), allowing for cross-compilation and efficient execution. Keep in mind that each alternative has its strengths and weaknesses, and the choice of which one to use depends on specific requirements and goals.
Related benchmarks:
eval vs new Function vs mathjs compiled
eval vs new Function vs mathjs 11
eval vs new Function vs mathjs v2
Mathjs Performance
Comments
Confirm delete:
Do you really want to delete benchmark?