Some benchmarks of community-made JavaScript/TypeScript libraries for converting units.
Generated automatically at Thu, 09 Jan 2025 02:54:52 GMT with Node.js v22.12.0 (V8 v12.4.254.21-node.21) on fv-az777-705 (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 |
convert (fast) | 110 ns (220%) |
111 ns (222%) |
9,090,909 /sec |
convert-units (popular) | 110 ns (220%) |
110 ns (220%) |
9,090,909 /sec |
simple-units (fast) | 161 ns (322%) |
170 ns (340%) |
6,211,180 /sec |
uom (fast) | 230 ns (460%) |
240 ns (480%) |
4,347,826 /sec |
moment (popular) | 371 ns (742%) |
381 ns (762%) |
2,695,418 /sec |
safe-units (fast) | 461 ns (922%) |
461 ns (922%) |
2,169,197 /sec |
dayjs (popular) | 552 ns (1,104%) |
571 ns (1,142%) |
1,811,594 /sec |
luxon (popular) | 1,052 ns (2,104%) |
1,062 ns (2,124%) |
950,570 /sec |
js-quantities (popular) | 2,003 ns (4,006%) |
2,023 ns (4,046%) |
499,251 /sec |
Library | Median execution time | 75th percentile execution time | Executions per second |
---|---|---|---|
convert (fast) | 591 ns (100%) |
671 ns (114%) |
1,692,047 /sec |
convert-units (popular) | 1,282 ns (217%) |
1,382 ns (234%) |
780,031 /sec |
byte-size (popular) | 26,639 ns (4,507%) |
28,287 ns (4,786%) |
37,539 /sec |
Library | Median execution time | 75th percentile execution time | Executions per second |
---|---|---|---|
math (baseline) | 60 ns (100%) |
60 ns (100%) |
16,666,667 /sec |
convert-units (popular) | 101 ns (168%) |
110 ns (183%) |
9,900,990 /sec |
convert (fast) | 111 ns (185%) |
120 ns (200%) |
9,009,009 /sec |
simple-units (fast) | 130 ns (217%) |
140 ns (233%) |
7,692,308 /sec |
uom (fast) | 220 ns (367%) |
221 ns (368%) |
4,545,455 /sec |
safe-units (fast) | 461 ns (768%) |
461 ns (768%) |
2,169,197 /sec |
js-quantities (popular) | 2,095 ns (3,492%) |
2,115 ns (3,525%) |
477,327 /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) | 120 ns (240%) |
120 ns (240%) |
8,333,333 /sec |
simple-units (fast) | 120 ns (240%) |
130 ns (260%) |
8,333,333 /sec |
convert-units (popular) | 130 ns (260%) |
130 ns (260%) |
7,692,308 /sec |
uom (fast) | 481 ns (962%) |
500 ns (1,000%) |
2,079,002 /sec |
safe-units (fast) | 1,102 ns (2,204%) |
1,112 ns (2,224%) |
907,441 /sec |
js-quantities (popular) | 2,887 ns (5,774%) |
2,907 ns (5,814%) |
346,380 /sec |
Library | Median execution time | 75th percentile execution time | Executions per second |
---|---|---|---|
ms (popular) | 200 ns (100%) |
201 ns (100%) |
5,000,000 /sec |
@lukeed/ms (fast) | 230 ns (115%) |
231 ns (116%) |
4,347,826 /sec |
convert (fast) | 281 ns (141%) |
290 ns (145%) |
3,558,719 /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) | 91 ns (182%) |
100 ns (200%) |
10,989,011 /sec |