-
-
Notifications
You must be signed in to change notification settings - Fork 33
replace ms
w/ @lukeed/ms
#230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SukkaW
wants to merge
1
commit into
dimdenGD:main
Choose a base branch
from
SukkaW:replace-ms
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+15
−5
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test fails...
Try to change this const ms = require('@lukeed/ms'); into this const { parse } = require('@lukeed/ms');
const ms = parse; |
Oops, I thought it was a drop-in replacement. |
Fixed in cc @cesco69 |
cc @dimdenGD |
is it still extra performant in node v20 / v22? const { run, bench, summary } = require('mitata');
const msVercel = require('ms');
const msLukeed = require('@lukeed/ms');
const msItty = require('itty-time');
const prettyMs = require('pretty-ms').default;
const toMs = require('@sindresorhus/to-milliseconds').default;
const humanizeDuration = require('humanize-duration');
summary(() => {
bench('vercel/ms: ms->string', () => {
msVercel(60000);
});
bench('lukeed/ms: ms->string', () => {
msLukeed.format(60000);
});
bench('itty-time: ms->string', () => {
msItty.ms(60000);
});
bench('pretty-ms: ms->string', () => {
prettyMs(60000, { verbose: true });
});
bench('humanize-duration: ms->string', () => {
humanizeDuration(60000);
});
});
summary(() => {
bench('vercel/ms: string->ms', () => {
msVercel('1 minute');
});
bench('lukeed/ms: string->ms', () => {
msLukeed.parse('1 minute');
});
bench('itty-time: string->ms', () => {
msItty.ms('1 minute');
});
bench('to-milliseconds: object->ms', () => {
toMs({minutes: 1});
});
});
run({ gc: 'inner' }) cpu: AMD Ryzen AI 9 HX 370 w/ Radeon 890M
runtime: node 22.16.0 (x64-linux)
benchmark avg (min … max) p75 / p99 (min … top 1%)
-------------------------------------------- -------------------------------
vercel/ms: ms->string 1.40 ns/iter 1.39 ns █
(1.26 ns … 14.67 ns) 1.50 ns █▃
( 0.10 b … 113.19 b) 0.11 b ▁▁▁▁▁▁▁▁▁▁██▁▁▁▁▁▁▁▁▁
lukeed/ms: ms->string 1.34 ns/iter 1.33 ns █
(1.27 ns … 18.52 ns) 1.63 ns █
( 0.11 b … 53.49 b) 0.12 b ▁▁▂█▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
itty-time: ms->string 778.52 ps/iter 772.71 ps █
(733.64 ps … 28.51 ns) 880.37 ps █
( 0.11 b … 18.13 b) 0.11 b ▁▁▁▁▃█▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁
pretty-ms: ms->string 180.36 ns/iter 183.18 ns █
(173.58 ns … 308.03 ns) 203.30 ns ██
(496.42 b … 1.11 kb) 688.60 b ▂███▄▃▃▃▂▄▄▄▂▂▂▁▁▁▁▁▁
humanize-duration: ms->string 330.33 ns/iter 332.60 ns ▅█
(321.84 ns … 410.51 ns) 354.93 ns ▃███
(459.12 b … 1.41 kb) 825.48 b ▃█████▃▃▂▆▇▅▃▃▂▂▁▁▂▁▁
summary
itty-time: ms->string
1.72x faster than lukeed/ms: ms->string
1.79x faster than vercel/ms: ms->string
231.68x faster than pretty-ms: ms->string
424.31x faster than humanize-duration: ms->string
-------------------------------------------- -------------------------------
vercel/ms: string->ms 50.09 ns/iter 49.65 ns █
(45.15 ns … 129.74 ns) 64.62 ns ▆█
( 19.07 b … 450.14 b) 251.42 b ▁▂▂███▃▂▁▁▁▁▁▁▁▁▂▂▂▁▁
lukeed/ms: string->ms 44.18 ns/iter 43.59 ns █
(41.98 ns … 85.26 ns) 59.30 ns █▃
( 68.05 b … 286.29 b) 198.63 b ▃██▃▁▁▁▁▁▁▁▁▁▁▁▁▁▂▁▁▁
itty-time: string->ms 49.10 ns/iter 48.53 ns █▂
(45.58 ns … 160.23 ns) 73.02 ns ██
(100.82 b … 453.51 b) 200.28 b ▁██▇▁▁▁▁▁▁▂▂▁▁▁▁▁▁▁▁▁
to-milliseconds: object->ms 57.57 ns/iter 57.05 ns █
(52.90 ns … 99.20 ns) 73.05 ns █
( 60.86 b … 542.02 b) 171.56 b ▁▁▁▆█▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
summary
lukeed/ms: string->ms
1.11x faster than itty-time: string->ms
1.13x faster than vercel/ms: string->ms
1.3x faster than to-milliseconds: object->ms |
Well, with your own benchmark, it shows |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@lukeed/ms
is a fork of Vercel's ms and improves the performance by 20%, yet the package is way smaller. That PR is never merged by Vercel til this day, and lukeed decides to maintain his fork instead.This PR replaces
ms
with/@lukeed/ms
.