Skip to content
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

Typescript rewrite #360

Merged
merged 170 commits into from
Feb 13, 2025
Merged

Typescript rewrite #360

merged 170 commits into from
Feb 13, 2025

Conversation

harrisiirak
Copy link
Owner

This MR is a long-awaited modernization of this library, converting the existing codebase to TypeScript. Kudos to @MichaelLeeHobbs (most of the changes come from his MR), who started this initiative - without whom this wouldn't have been possible.

There have been some changes to the public API, resulting in a few breaking changes that need to be considered when switching to this version. Additionally, some bugs and minor performance regressions were fixed during the refactor.

Changelog

Performance improvements

While this release won't address the performance issues reported in #287, it will bring some performance improvements of around 20-30% on average, depending on the pattern complexity. The following benchmark results were produced on my 2023 MBP.

┌────────────────────┬────────────┬────────────┬──────────┬─────┐
│ Pattern            │   Old Mean │   New Mean │   Change │     │
├────────────────────┼────────────┼────────────┼──────────┼─────┤
│ * * * * * *        │    73.55ms │    37.43ms │   49.10% │  ↑  │
├────────────────────┼────────────┼────────────┼──────────┼─────┤
│ 0 * * 1,4-10,L * * │  3504.51ms │  2338.42ms │   33.27% │  ↑  │
├────────────────────┼────────────┼────────────┼──────────┼─────┤
│ 10-30/2 2 12 8 0   │  3111.18ms │  2234.32ms │   28.18% │  ↑  │
├────────────────────┼────────────┼────────────┼──────────┼─────┤
│ 0 0 0 * * 4,6L     │  9400.33ms │  6825.61ms │   27.39% │  ↑  │
├────────────────────┼────────────┼────────────┼──────────┼─────┤
│ 0 12 */5 6 *       │  7442.68ms │  5645.95ms │   24.14% │  ↑  │
├────────────────────┼────────────┼────────────┼──────────┼─────┤
│ 0 15 */5 5 *       │  6998.87ms │  5443.22ms │   22.23% │  ↑  │
├────────────────────┼────────────┼────────────┼──────────┼─────┤
│ 0 0 6-20/2,L 2 *   │  8832.87ms │  6947.63ms │   21.34% │  ↑  │
├────────────────────┼────────────┼────────────┼──────────┼─────┤
│ 0 0 0 * * 1L,5L    │ 15416.07ms │ 12474.12ms │   19.08% │  ↑  │
├────────────────────┼────────────┼────────────┼──────────┼─────┤
│ 10 2 12 8 7        │  7105.79ms │  5947.91ms │   16.29% │  ↑  │
└────────────────────┴────────────┴────────────┴──────────┴─────┘

Benchmarks can be run locally by executing the command.:

npm run bench

Individual patterns can be benchmarked by executing bench:pattern command:

npm run bench:pattern "* * * * * *"

… of coverage on CronParser, not sure why yet. Added a lot of FIXME's for things that don't make sense or aren't needed. Phase 2 basically done. Phase 3 will be a code review.
@harrisiirak harrisiirak self-assigned this Feb 13, 2025
@harrisiirak harrisiirak merged commit b5f4194 into master Feb 13, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment