Some benchmarks of community-made JavaScript/TypeScript libraries for converting units.
Generated automatically at Wed, 01 Jan 2025 03:40:47 GMT with Node.js v22.12.0 (V8 v12.4.254.21-node.21) on fv-az1249-509 (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-units (popular) | 110 ns (220%) |
110 ns (220%) |
9,090,909 /sec |
convert (fast) | 111 ns (222%) |
120 ns (240%) |
9,009,009 /sec |
simple-units (fast) | 130 ns (260%) |
131 ns (262%) |
7,692,308 /sec |
uom (fast) | 241 ns (482%) |
250 ns (500%) |
4,149,378 /sec |
moment (popular) | 411 ns (822%) |
421 ns (842%) |
2,433,090 /sec |
safe-units (fast) | 431 ns (862%) |
440 ns (880%) |
2,320,186 /sec |
dayjs (popular) | 541 ns (1,082%) |
561 ns (1,122%) |
1,848,429 /sec |
luxon (popular) | 1,042 ns (2,084%) |
1,062 ns (2,124%) |
959,693 /sec |
js-quantities (popular) | 2,023 ns (4,046%) |
2,043 ns (4,086%) |
494,315 /sec |
Library | Median execution time | 75th percentile execution time | Executions per second |
---|---|---|---|
convert (fast) | 591 ns (100%) |
642 ns (109%) |
1,692,047 /sec |
convert-units (popular) | 1,202 ns (203%) |
1,293 ns (219%) |
831,947 /sec |
byte-size (popular) | 26,847 ns (4,543%) |
28,399 ns (4,805%) |
37,248 /sec |
Library | Median execution time | 75th percentile execution time | Executions per second |
---|---|---|---|
math (baseline) | 60 ns (100%) |
70 ns (117%) |
16,666,667 /sec |
convert-units (popular) | 100 ns (167%) |
110 ns (183%) |
10,000,000 /sec |
simple-units (fast) | 100 ns (167%) |
110 ns (183%) |
10,000,000 /sec |
convert (fast) | 111 ns (185%) |
120 ns (200%) |
9,009,009 /sec |
uom (fast) | 220 ns (367%) |
230 ns (383%) |
4,545,455 /sec |
safe-units (fast) | 450 ns (750%) |
451 ns (752%) |
2,222,222 /sec |
js-quantities (popular) | 2,105 ns (3,508%) |
2,125 ns (3,542%) |
475,059 /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%) |
130 ns (260%) |
8,333,333 /sec |
simple-units (fast) | 120 ns (240%) |
121 ns (242%) |
8,333,333 /sec |
convert-units (popular) | 130 ns (260%) |
140 ns (280%) |
7,692,308 /sec |
uom (fast) | 501 ns (1,002%) |
541 ns (1,082%) |
1,996,008 /sec |
safe-units (fast) | 1,103 ns (2,206%) |
1,113 ns (2,226%) |
906,618 /sec |
js-quantities (popular) | 2,885 ns (5,770%) |
2,915 ns (5,830%) |
346,620 /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) | 280 ns (140%) |
281 ns (141%) |
3,571,429 /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 |