Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
bigint vs. bignumber.js vs. big.js vs. break_infinity.js
(version: 0)
- https://github.com/MikeMcl/bignumber.js/tree/v9.0.0 - https://github.com/MikeMcl/big.js/tree/v5.2.2 - https://github.com/MikeMcl/decimal.js/tree/v10.2.0
Comparing performance of:
BigInt vs break_infinity.js vs big.js vs bignumber.js
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--script src="https://raw.githubusercontent.com/iriscouch/bigdecimal.js/v0.6.1/lib/bigdecimal.js"></script--> <script src="https://cdnjs.cloudflare.com/ajax/libs/bignumber.js/9.0.1/bignumber.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/big.js/6.0.3/big.min.js"></script> <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/decimal.js/10.2.1/decimal.min.js"></script>--> <script src="https://cdn.jsdelivr.net/npm/break_infinity.js@2"></script> <!--script src="https://raw.githubusercontent.com/infusion/Fraction.js/v4.0.12/fraction.min.js"></script-->
Tests:
BigInt
var a = 100n; var b = 2000000000000000000000000000000000001n; ((a + b) * b).toString();
break_infinity.js
var a = new Decimal("100"); var b = new Decimal("2000000000000000000000000000000000001"); a.plus(b).times(b).toString();
big.js
var a = new Big("100"); var b = new Big("2000000000000000000000000000000000001"); a.plus(b).mul(b).toString();
bignumber.js
var a = new BigNumber("100"); var b = new BigNumber("2000000000000000000000000000000000001"); a.plus(b).multipliedBy(b).toString();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
BigInt
break_infinity.js
big.js
bignumber.js
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:127.0) Gecko/20100101 Firefox/127.0
Browser/OS:
Firefox 127 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
BigInt
4317238.5 Ops/sec
break_infinity.js
2386646.8 Ops/sec
big.js
84298.1 Ops/sec
bignumber.js
816993.4 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the explanation of what is being tested on this benchmark. The benchmark tests four different libraries: `bigint`, `bignumber.js`, `big.js`, and `break_infinity.js`. The test case, "BigInt", uses the native JavaScript `BigInt` type to perform an arithmetic operation. Specifically, it calculates `(a + b) * b`, where `a` is a small integer (100n) and `b` is a large integer (2000000000000000000000000000000000001n). The other test cases use different libraries to perform the same calculation: * `break_infinity.js`: This library provides support for arbitrary-precision arithmetic. It creates instances of its `Decimal` class, `a` and `b`, to represent the large integers. * `big.js`: Similar to `break_infinity.js`, it also uses its `Big` class to create instances representing large integers, `a` and `b`. * `bignumber.js`: This library creates instances of its `BigNumber` class, `a` and `b`, to represent the large integers. Now let's discuss pros and cons for each approach: 1. **Native JavaScript BigInt type**: The native `BigInt` type provides a performance benefit since it is implemented in native code. * Pros: Native code execution results in better performance compared to libraries, especially for small integers where the overhead of library function calls can be significant. * Cons: Not available in older browsers or those without native support. 2. **break\_infinity.js**: This library provides a flexible and easy-to-use API with good browser support. * Pros: Good performance due to its native-precision arithmetic, flexible usage for calculations involving large numbers. * Cons: It has some compatibility issues across browsers. 3. **big.js**: Offers fast execution times and supports a wide range of devices and browsers. * Pros: Good performance with support for older versions and a comprehensive set of features. * Cons: Requires extra initialization due to its high-level design. 4. **bignumber.js**: This library provides good browser compatibility, is easy to use, and includes many useful mathematical functions out-of-the-box. * Pros: Good performance with wide browser support and a user-friendly API. * Cons: Higher than `break_infinity.js` due to its implementation details. In terms of the libraries used in this benchmark, here's their purpose: * **break\_infinity.js** : Provides support for arbitrary-precision arithmetic. * **big.js**: Offers fast execution times and supports a wide range of devices and browsers. * **bignumber.js**: Provides good browser compatibility and includes many useful mathematical functions. Other alternatives to these libraries include `decimal.js`, which provides decimal floating-point arithmetic, and `fraction.js`, which provides rational numbers. For the special JavaScript feature used in this benchmark, it is native `BigInt` support.
Related benchmarks:
bignumber.js vs. big.js vs. decimal.js (I) no native
bigint vs. bignumber.js vs. big.js vs. decimal.js
bigint vs. bignumber.js vs. big.js vs. decimal.js with exponentiation
bignumber.js vs. big.js vs. decimal.js@10.4.3 (I)
Comments
Confirm delete:
Do you really want to delete benchmark?