Skip to content

Commit

Permalink
Update benchmark (#145)
Browse files Browse the repository at this point in the history
* Update lib versions

* Update readme about benchmark
  • Loading branch information
srknzl authored Jan 28, 2024
1 parent cab611f commit e95a416
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,32 +100,32 @@ For now, benchmarked against [big.js](https://www.npmjs.com/package/big.js) and
* Test Machine:
* M1 2021 MacBook Air
* 16 GB Ram
* MacOS Monterey 13.0 (22A380)
* Update Date: November 19th 2022
* MacOS Sonoma 14.2.1
* Update Date: January 28th 2024
* Library versions used:
* big.js 6.2.1
* (this library) bigdecimal.js 1.3.0
* (this library) bigdecimal.js 1.3.1
* bigdecimal 0.6.1
* bignumber.js: 9.1.0
* decimal.js:10.4.2
* bignumber.js: 9.1.2
* decimal.js:10.4.3

* Each operation is run with fixed set of decimal numbers composed of both simple and complex numbers.
* Micro benchmark framework used is [benchmark](https://www.npmjs.com/package/benchmark). Check out [benchmarks folder](https://github.com/srknzl/bigdecimal.js/tree/main/benchmarks) for source code of benchmarks.
* For now, benchmarked the following operations, more operations will be added soon.
* For now, benchmarked the following operations, more operations will be added later.
* Operations per second(op/s):

| Operation | Bigdecimal.js | Big.js | BigNumber.js | decimal.js | GWTBased |
| --- | --- | --- | --- | --- | --- |
| Constructor | 43,477 ( - ) | 38,808 (<span style="color:red">-11%</span>) | 42,178 (<span style="color:red">-3%</span>) | 42,075 (<span style="color:red">-3%</span>) | 2,812 (<span style="color:red">-94%</span>) |
| Add | 79,582 ( - ) | 18,122 (<span style="color:red">-77%</span>) | 100,120 (<span style="color:green">**+26%**</span>) | 59,636 (<span style="color:red">-25%</span>) | 89 (<span style="color:red">-100%</span>) |
| Subtract | 74,226 ( - ) | 17,987 (<span style="color:red">-76%</span>) | 95,876 (<span style="color:green">**+29%**</span>) | 56,405 (<span style="color:red">-24%</span>) | 89 (<span style="color:red">-100%</span>) |
| Multiply | 498,374 ( - ) | 33,113 (<span style="color:red">-93%</span>) | 26,852 (<span style="color:red">-95%</span>) | 79,178 (<span style="color:red">-84%</span>) | 2,695 (<span style="color:red">-99%</span>) |
| Divide | 15,246 ( - ) | 1,129 (<span style="color:red">-93%</span>) | 11,575 (<span style="color:red">-24%</span>) | 13,700 (<span style="color:red">-10%</span>) | 673 (<span style="color:red">-96%</span>) |
| Remainder | 9,667 ( - ) | 3,888 (<span style="color:red">-60%</span>) | 13,541 (<span style="color:green">**+40%**</span>) | 22,060 (<span style="color:green">**+128%**</span>) | 2,585 (<span style="color:red">-73%</span>) |
| Positive pow | 27,675 ( - ) | 25 (<span style="color:red">-100%</span>) | 112 (<span style="color:red">-100%</span>) | 3,455 (<span style="color:red">-88%</span>) | 6 (<span style="color:red">-100%</span>) |
| Negative pow | 5,028 ( - ) | 21 (<span style="color:red">-100%</span>) | 109 (<span style="color:red">-98%</span>) | 1,953 (<span style="color:red">-61%</span>) | 276 (<span style="color:red">-95%</span>) |
| Abs | 781,477 ( - ) | 1,396,972 (<span style="color:green">**+79%**</span>) | 909,314 (<span style="color:green">**+16%**</span>) | 366,702 (<span style="color:red">-53%</span>) | 14,010 (<span style="color:red">-98%</span>) |
| Compare | 544,100 ( - ) | 1,188,332 (<span style="color:green">**+118%**</span>) | 776,758 (<span style="color:green">**+43%**</span>) | 426,463 (<span style="color:red">-22%</span>) | 1,004,854 (<span style="color:green">**+85%**</span>) |
| Constructor | 43,962 ( - ) | 38,238 (<span style="color:red">-13%</span>) | 42,337 (<span style="color:red">-4%</span>) | 42,355 (<span style="color:red">-4%</span>) | 2,818 (<span style="color:red">-94%</span>) |
| Add | 80,569 ( - ) | 18,406 (<span style="color:red">-77%</span>) | 100,734 (<span style="color:green">**+25%**</span>) | 59,815 (<span style="color:red">-26%</span>) | 90 (<span style="color:red">-100%</span>) |
| Subtract | 73,518 ( - ) | 18,265 (<span style="color:red">-75%</span>) | 96,022 (<span style="color:green">**+31%**</span>) | 57,130 (<span style="color:red">-22%</span>) | 89 (<span style="color:red">-100%</span>) |
| Multiply | 493,291 ( - ) | 33,422 (<span style="color:red">-93%</span>) | 26,810 (<span style="color:red">-95%</span>) | 79,995 (<span style="color:red">-84%</span>) | 2,609 (<span style="color:red">-99%</span>) |
| Divide | 15,341 ( - ) | 1,129 (<span style="color:red">-93%</span>) | 11,721 (<span style="color:red">-24%</span>) | 13,301 (<span style="color:red">-13%</span>) | 645 (<span style="color:red">-96%</span>) |
| Remainder | 9,362 ( - ) | 3,816 (<span style="color:red">-59%</span>) | 13,470 (<span style="color:green">**+44%**</span>) | 21,952 (<span style="color:green">**+134%**</span>) | 2,445 (<span style="color:red">-74%</span>) |
| Positive pow | 27,403 ( - ) | 25 (<span style="color:red">-100%</span>) | 113 (<span style="color:red">-100%</span>) | 3,535 (<span style="color:red">-87%</span>) | 6 (<span style="color:red">-100%</span>) |
| Negative pow | 4,863 ( - ) | 21 (<span style="color:red">-100%</span>) | 109 (<span style="color:red">-98%</span>) | 1,970 (<span style="color:red">-59%</span>) | 264 (<span style="color:red">-95%</span>) |
| Abs | 782,251 ( - ) | 1,424,376 (<span style="color:green">**+82%**</span>) | 917,526 (<span style="color:green">**+17%**</span>) | 358,678 (<span style="color:red">-54%</span>) | 14,132 (<span style="color:red">-98%</span>) |
| Compare | 546,243 ( - ) | 1,216,388 (<span style="color:green">**+123%**</span>) | 783,432 (<span style="color:green">**+43%**</span>) | 417,873 (<span style="color:red">-24%</span>) | 990,187 (<span style="color:green">**+81%**</span>) |

[npm-image]: https://img.shields.io/npm/v/bigdecimal.js.svg
[npm-url]: https://npmjs.org/package/bigdecimal.js
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
"benchmark": "^2.1.4",
"big.js": "^6.2.1",
"bigdecimal": "^0.6.1",
"bignumber.js": "^9.1.0",
"bignumber.js": "^9.1.2",
"chai": "^4.3",
"decimal.js": "^10.4.2",
"decimal.js": "^10.4.3",
"eslint": "^8.56.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
Expand Down

0 comments on commit e95a416

Please sign in to comment.