Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
JS Big Integers v4
(version: 0)
Comparing performance of:
SJCL BN vs BigInteger.js vs native BigInt
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://rawgit.com/bitwiseshiftleft/sjcl/master/sjcl.js"></script> <script src="https://rawgit.com/bitwiseshiftleft/sjcl/master/core/bn.js"></script> <script src="https://rawgit.com/peterolson/BigInteger.js/master/BigInteger.min.js"></script>
Script Preparation code:
var n1 = "f10853b38e67ed882bc0284b8e71581469806699e8a028a19cd8cac913a3f8b859ee0999833886f13987ecf4ed3a11cf6aabd0b074531f5ef338f624e62429ff"; var n2 = "d978cfde1678dc8ce9dab4bfe2e1fa8be09a5668cd8e607cc24f28e440495c7f4b5317d6533e3fb232ebce63fab872ece25935a5cacc5cb8a94b5"; var five = "5";
Tests:
SJCL BN
a = new sjcl.bn(n1); b = new sjcl.bn(n2); c = a.sub(b); c = a.mod(b); c = a.mul(b); c = a.add(b); c = a.powermod(new sjcl.bn(five), b);
BigInteger.js
a = bigInt(n1, 16); b = bigInt(n2, 16); c = a.subtract(b); c = a.mod(b); c = a.multiply(b); c = a.add(b); c = a.modPow(bigInt(five), b);
native BigInt
a = BigInt('0x' + n1); b = BigInt('0x' + n2); c = a - b; c = a % b; c = a * b; c = a + b; c = a ** BigInt(five) % b;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
SJCL BN
BigInteger.js
native BigInt
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
The provided JSON represents a benchmark for measuring the performance of three different libraries for handling large integers in JavaScript: SJCL, BigInteger.js, and native BigInt. **Library Overview** * **SJCL (Secure JavaScript Computing Library)**: A library for secure JavaScript computations. It provides a modular arithmetic system with support for big numbers. * **BigInteger.js**: A lightweight library for working with large integers in JavaScript. * **Native BigInt**: The built-in support for arbitrary-precision integers in JavaScript, introduced in ECMAScript 2020. **Tested Operations** The benchmark compares the performance of each library when performing various operations on large integers: 1. Subtraction (`a - b`) 2. Modulus (`a % b`) 3. Multiplication (`a * b`) 4. Addition (`a + b`) 5. Modular exponentiation (`a ** BigInt(five) % b`) **Options Compared** The benchmark compares the performance of each library for the same set of operations: 1. SJCL BN 2. BigInteger.js 3. Native BigInt **Pros and Cons** * **SJCL BN**: Pros: Provides a modular arithmetic system, supports secure computations. Cons: Has some overhead due to its security-focused design. * **BigInteger.js**: Pros: Lightweight, easy to use. Cons: May not be as efficient as other libraries. * **Native BigInt**: Pros: Built-in support, high performance. Cons: Only available in ECMAScript 2020 and later browsers. **Library-Specific Considerations** * **SJCL BN**: Uses a modular arithmetic system, which can be beneficial for secure computations. However, this comes at the cost of some overhead. * **BigInteger.js**: A lightweight library with a simple API. While it may not be as efficient as other libraries, it's easy to use and suitable for many applications. * **Native BigInt**: The built-in support for arbitrary-precision integers in JavaScript is highly optimized and performs well. However, it's only available in ECMAScript 2020 and later browsers. **Other Alternatives** There are other libraries available for handling large integers in JavaScript, such as: * **jsbn**: A lightweight library for working with big numbers. * **decimal.js**: A library for decimal arithmetic that can also be used for large integer operations. It's worth noting that the choice of library depends on the specific use case and requirements. For example, if security is a concern, SJCL BN might be a good choice. If performance is crucial and the browser supports ECMAScript 2020, Native BigInt could be a better option.
Related benchmarks:
bignumber.js vs. big.js vs. decimal.js 2022 ver. (random)
bignumber.js vs. big.js vs. decimal.js 2022 ver. (random) (no toFixed)
bigint vs. bignumber.js vs. big.js vs. decimal.js
bigint vs. bignumber.js vs. big.js vs. decimal.js with exponentiation
bigint vs. bignumber.js vs. big.js vs. break_infinity.js
Comments
Confirm delete:
Do you really want to delete benchmark?