Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
my test decimal spread
- https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Number - 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
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 YaBrowser/26.3.0.0 Safari/537.36
Browser:
Yandex Browser 26
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
19 days ago
Test name
Executions per second
native
18240444.0 Ops/sec
decimal.js
933637.2 Ops/sec
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://raw.githubusercontent.com/infusion/Fraction.js/v4.0.12/fraction.min.js"></script-->
Tests:
bigint
const precision = 1e8; const bpsPrecision = BigInt(1e4); const a = BigInt('123456'); const b = BigInt('124456'); const c = ((b * bpsPrecision) / a) - bpsPrecision;
decimal.js
const a = new Decimal('123.456'); const b = new Decimal('123.456'); const c = b.div(a).minus(1).mul(1e4)
native (parseFloat int)
const precision = 1e8; const a = Math.trunc(parseFloat('12345.6')); const b = Math.trunc(parseFloat('12445.6')); const c = Math.trunc(((b * 1e4) / a) - 1e4);
native (float)
const precision = 1e8; const a = parseFloat('123.456'); const b = parseFloat('124.456'); const c = ((b * 1e4) / a) - 1e4;
native (int parseInt)
const precision = 1e8; const a = parseInt('12345.6'); const b = parseInt('12445.6'); const c = Math.trunc(((b * 1e4) / a) - 1e4);