Some benchmarks of community-made JavaScript/TypeScript libraries for converting units.
Generated automatically at Wed, 11 Dec 2024 15:54:51 GMT with Node.js v22.11.0 (V8 v12.4.254.21-node.21) on fv-az1040-926 (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.
Library | Median execution time | 75th percentile execution time | Executions per second |
---|---|---|---|
math (baseline) | 50 ns (100%) |
50 ns (100%) |
20,000,000 /sec |
simple-units (fast) | 100 ns (200%) |
101 ns (202%) |
10,000,000 /sec |
convert (fast) | 110 ns (220%) |
110 ns (220%) |
9,090,909 /sec |
convert-units (popular) | 110 ns (220%) |
110 ns (220%) |
9,090,909 /sec |
uom (fast) | 230 ns (460%) |
240 ns (480%) |
4,347,826 /sec |
moment (popular) | 381 ns (762%) |
381 ns (762%) |
2,624,672 /sec |
safe-units (fast) | 451 ns (902%) |
461 ns (922%) |
2,217,295 /sec |
dayjs (popular) | 541 ns (1,082%) |
561 ns (1,122%) |
1,848,429 /sec |
luxon (popular) | 1,042 ns (2,084%) |
1,052 ns (2,104%) |
959,693 /sec |
js-quantities (popular) | 1,994 ns (3,988%) |
2,014 ns (4,028%) |
501,505 /sec |
Library | Median execution time | 75th percentile execution time | Executions per second |
---|---|---|---|
convert (fast) | 601 ns (100%) |
681 ns (113%) |
1,663,894 /sec |
convert-units (popular) | 1,102 ns (183%) |
1,193 ns (199%) |
907,441 /sec |
byte-size (popular) | 26,655 ns (4,435%) |
28,351 ns (4,717%) |
37,516 /sec |
Library | Median execution time | 75th percentile execution time | Executions per second |
---|---|---|---|
math (baseline) | 70 ns (100%) |
70 ns (100%) |
14,285,714 /sec |
convert-units (popular) | 110 ns (157%) |
111 ns (159%) |
9,090,909 /sec |
convert (fast) | 111 ns (159%) |
121 ns (173%) |
9,009,009 /sec |
simple-units (fast) | 120 ns (171%) |
120 ns (171%) |
8,333,333 /sec |
uom (fast) | 210 ns (300%) |
221 ns (316%) |
4,761,905 /sec |
safe-units (fast) | 441 ns (630%) |
450 ns (643%) |
2,267,574 /sec |
js-quantities (popular) | 2,085 ns (2,979%) |
2,105 ns (3,007%) |
479,616 /sec |
Library | Median execution time | 75th percentile execution time | Executions per second |
---|---|---|---|
math (baseline) | 50 ns (100%) |
50 ns (100%) |
20,000,000 /sec |
simple-units (fast) | 110 ns (220%) |
120 ns (240%) |
9,090,909 /sec |
convert-units (popular) | 121 ns (242%) |
130 ns (260%) |
8,264,463 /sec |
convert (fast) | 130 ns (260%) |
130 ns (260%) |
7,692,308 /sec |
uom (fast) | 501 ns (1,002%) |
511 ns (1,022%) |
1,996,008 /sec |
safe-units (fast) | 1,132 ns (2,264%) |
1,142 ns (2,284%) |
883,392 /sec |
js-quantities (popular) | 2,895 ns (5,790%) |
2,917 ns (5,834%) |
345,423 /sec |
Library | Median execution time | 75th percentile execution time | Executions per second |
---|---|---|---|
ms (popular) | 200 ns (100%) |
200 ns (100%) |
5,000,000 /sec |
@lukeed/ms (fast) | 230 ns (115%) |
231 ns (116%) |
4,347,826 /sec |
convert (fast) | 270 ns (135%) |
271 ns (136%) |
3,703,704 /sec |
Library | Median execution time | 75th percentile execution time | Executions per second |
---|---|---|---|
math (baseline) | 50 ns (100%) |
50 ns (100%) |
20,000,000 /sec |
convert (fast) | 100 ns (200%) |
100 ns (200%) |
10,000,000 /sec |