https://github.com/jonahsnider/js-unit-conversion-benchmarks
Some benchmarks of community-made JavaScript libraries for converting units.
https://github.com/jonahsnider/js-unit-conversion-benchmarks
benchmark converting-units hacktoberfest trials
Last synced: 13 days ago
JSON representation
Some benchmarks of community-made JavaScript libraries for converting units.
- Host: GitHub
- URL: https://github.com/jonahsnider/js-unit-conversion-benchmarks
- Owner: jonahsnider
- Created: 2020-12-22T12:18:58.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-05-06T02:43:40.000Z (15 days ago)
- Last Synced: 2025-05-06T03:31:00.378Z (15 days ago)
- Topics: benchmark, converting-units, hacktoberfest, trials
- Language: TypeScript
- Homepage:
- Size: 13.5 MB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# JavaScript unit conversion benchmarks
Some benchmarks of community-made JavaScript/TypeScript libraries for converting units.
## Results
Generated automatically at Wed, 07 May 2025 22:12:02 GMT with Node.js v22.15.0 (V8 v12.4.254.21-node.24) on fv-az1341-848 (Linux-x64 AMD EPYC 7763 64-Core Processor)
Each test was called 10,000 times to allow the runtime to warmup.
Afterward 100,000 trials were performed for each library.
Information about the execution times are shown below.
Lower execution times and higher executions per second are better.A baseline of raw math is included when relevant.
If you want a different library to be added to the benchmark, make an issue or create a pull request if you're comfortable.
### Convert 24 hours to minutes
| Library | Median execution time | 75th percentile execution time | Executions per second |
| ------------------------------------------------------------------ | --------------------- | ------------------------------ | --------------------- |
| math (baseline) | `50`ns (100%) | `50`ns (100%) | `20,000,000`/sec |
| [convert](https://npmjs.com/package/convert) (fast) | `110`ns (220%) | `110`ns (220%) | `9,090,909`/sec |
| [convert-units](https://npmjs.com/package/convert-units) (popular) | `110`ns (220%) | `110`ns (220%) | `9,090,909`/sec |
| [simple-units](https://npmjs.com/package/simple-units) (fast) | `140`ns (280%) | `141`ns (282%) | `7,142,857`/sec |
| [uom](https://npmjs.com/package/uom) (fast) | `270`ns (540%) | `280`ns (560%) | `3,703,704`/sec |
| [moment](https://npmjs.com/package/moment) (popular) | `391`ns (782%) | `391`ns (782%) | `2,557,545`/sec |
| [safe-units](https://npmjs.com/package/safe-units) (fast) | `441`ns (882%) | `451`ns (902%) | `2,267,574`/sec |
| [dayjs](https://npmjs.com/package/dayjs) (popular) | `552`ns (1,104%) | `571`ns (1,142%) | `1,811,594`/sec |
| [luxon](https://npmjs.com/package/luxon) (popular) | `1,082`ns (2,164%) | `1,112`ns (2,224%) | `924,214`/sec |
| [js-quantities](https://npmjs.com/package/js-quantities) (popular) | `2,055`ns (4,110%) | `2,075`ns (4,150%) | `486,618`/sec |### Convert 8192 bytes to the best applicable unit
| Library | Median execution time | 75th percentile execution time | Executions per second |
| ------------------------------------------------------------------ | --------------------- | ------------------------------ | --------------------- |
| [convert](https://npmjs.com/package/convert) (fast) | `621`ns (100%) | `701`ns (113%) | `1,610,306`/sec |
| [convert-units](https://npmjs.com/package/convert-units) (popular) | `1,303`ns (210%) | `1,442`ns (232%) | `767,460`/sec |
| [byte-size](https://npmjs.com/package/byte-size) (popular) | `25,855`ns (4,163%) | `27,695`ns (4,460%) | `38,677`/sec |### Convert 4 inches to millimeters
| Library | Median execution time | 75th percentile execution time | Executions per second |
| ------------------------------------------------------------------ | --------------------- | ------------------------------ | --------------------- |
| math (baseline) | `50`ns (100%) | `50`ns (100%) | `20,000,000`/sec |
| [convert-units](https://npmjs.com/package/convert-units) (popular) | `110`ns (220%) | `111`ns (222%) | `9,090,909`/sec |
| [simple-units](https://npmjs.com/package/simple-units) (fast) | `131`ns (262%) | `140`ns (280%) | `7,633,588`/sec |
| [convert](https://npmjs.com/package/convert) (fast) | `140`ns (280%) | `141`ns (282%) | `7,142,857`/sec |
| [uom](https://npmjs.com/package/uom) (fast) | `250`ns (500%) | `251`ns (502%) | `4,000,000`/sec |
| [safe-units](https://npmjs.com/package/safe-units) (fast) | `471`ns (942%) | `481`ns (962%) | `2,123,142`/sec |
| [js-quantities](https://npmjs.com/package/js-quantities) (popular) | `2,065`ns (4,130%) | `2,085`ns (4,170%) | `484,262`/sec |### Convert 2.5 liters to cubic inches
| Library | Median execution time | 75th percentile execution time | Executions per second |
| ------------------------------------------------------------------ | --------------------- | ------------------------------ | --------------------- |
| math (baseline) | `50`ns (100%) | `50`ns (100%) | `20,000,000`/sec |
| [convert](https://npmjs.com/package/convert) (fast) | `111`ns (222%) | `120`ns (240%) | `9,009,009`/sec |
| [convert-units](https://npmjs.com/package/convert-units) (popular) | `120`ns (240%) | `130`ns (260%) | `8,333,333`/sec |
| [simple-units](https://npmjs.com/package/simple-units) (fast) | `120`ns (240%) | `121`ns (242%) | `8,333,333`/sec |
| [uom](https://npmjs.com/package/uom) (fast) | `511`ns (1,022%) | `530`ns (1,060%) | `1,956,947`/sec |
| [safe-units](https://npmjs.com/package/safe-units) (fast) | `1,112`ns (2,224%) | `1,122`ns (2,244%) | `899,281`/sec |
| [js-quantities](https://npmjs.com/package/js-quantities) (popular) | `2,895`ns (5,790%) | `2,925`ns (5,850%) | `345,423`/sec |### Parse "10h" and convert it to milliseconds
| Library | Median execution time | 75th percentile execution time | Executions per second |
| --------------------------------------------------------- | --------------------- | ------------------------------ | --------------------- |
| [ms](https://npmjs.com/package/ms) (popular) | `201`ns (100%) | `210`ns (104%) | `4,975,124`/sec |
| [@lukeed/ms](https://npmjs.com/package/@lukeed/ms) (fast) | `230`ns (114%) | `231`ns (115%) | `4,347,826`/sec |
| [convert](https://npmjs.com/package/convert) (fast) | `280`ns (139%) | `281`ns (140%) | `3,571,429`/sec |### Convert 24 hours to minutes, but with `bigint`s
| Library | Median execution time | 75th percentile execution time | Executions per second |
| --------------------------------------------------- | --------------------- | ------------------------------ | --------------------- |
| math (baseline) | `50`ns (100%) | `50`ns (100%) | `20,000,000`/sec |
| [convert](https://npmjs.com/package/convert) (fast) | `91`ns (182%) | `100`ns (200%) | `10,989,011`/sec |