- Notifications
You must be signed in to change notification settings - Fork514
PermalinkChoose a base ref {{ refName }}default Choose a head ref {{ refName }}default
Comparing changes
Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also orlearn more about diff comparisons.
Open a pull request
Create a new pull request by comparing changes across two branches. If you need to, you can also.Learn more about diff comparisons here.
base repository:npm/node-semver
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
Uh oh!
There was an error while loading.Please reload this page.
base:v7.6.2
Could not load branches
Nothing to show
Loading
Could not load tags
Nothing to show
{{ refName }}defaultLoading
...
head repository:npm/node-semver
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
Uh oh!
There was an error while loading.Please reload this page.
compare:v7.6.3
Could not load branches
Nothing to show
Loading
Could not load tags
Nothing to show
{{ refName }}defaultLoading
- 3commits
- 6files changed
- 3contributors
Commits on Jul 16, 2024
fix: optimize Range parsing and formatting (#726)
<!-- What / Why --><!-- Describe the request in detail. What it does and why it's beingchanged. -->This pull request optimizes the Range class in the following ways:1. Produce fewer intermediate objects when reducing a range's spacecharacters to single spaces. This seems to improve bench-subset scoresby up to 5%, and bench-satisfies scores to a lesser degree.2. Optimize Range formatting with explicit for loops instead, avoidingan intermediate array creation. This seems to improve bench-satisfiesand bench-subset scores by up to 20%.3. Calculate Range's `.range` string (used by `.format()` and`.toString()`) lazily. This seems to improve bench-satisfies andbench-subset scores by up to 9%.The external interface for the class stays the same, except for the newinternal `.formatted` property used to cache its lazily calculatedstring. `Range#range` property is now also read-only.There is a new test lazy formatting to ensure full test coverage.The benchmarks bench-satisfies and bench-subset benefit from thesechanges, sometimes by up to 40%. Other benchmark results seem to staythe same. Here are the affected benchmarks before:```$ node benchmarks/bench-satisfies.jssatisfies(1.0.6, 1.0.3||^2.0.0) x 695,094 ops/sec ±0.68% (97 runs sampled)satisfies(1.0.6, 2.2.2||~3.0.0) x 764,115 ops/sec ±0.40% (99 runs sampled)satisfies(1.0.6, 2.3.0||<4.0.0) x 805,593 ops/sec ±0.62% (97 runs sampled)satisfies(1.0.6, 1.0.3||^2.0.0, {"includePrelease":true}) x 695,045 ops/sec ±0.73% (95 runs sampled)satisfies(1.0.6, 2.2.2||~3.0.0, {"includePrelease":true}) x 750,433 ops/sec ±0.66% (99 runs sampled)satisfies(1.0.6, 2.3.0||<4.0.0, {"includePrelease":true}) x 787,903 ops/sec ±0.39% (99 runs sampled)satisfies(1.0.6, 1.0.3||^2.0.0, {"includePrelease":true,"loose":true}) x 652,166 ops/sec ±0.34% (99 runs sampled)satisfies(1.0.6, 2.2.2||~3.0.0, {"includePrelease":true,"loose":true}) x 696,377 ops/sec ±0.36% (96 runs sampled)satisfies(1.0.6, 2.3.0||<4.0.0, {"includePrelease":true,"loose":true}) x 721,729 ops/sec ±0.35% (98 runs sampled)satisfies(1.0.6, 1.0.3||^2.0.0, {"includePrelease":true,"loose":true,"rtl":true}) x 585,692 ops/sec ±0.75% (95 runs sampled)satisfies(1.0.6, 2.2.2||~3.0.0, {"includePrelease":true,"loose":true,"rtl":true}) x 631,653 ops/sec ±0.33% (96 runs sampled)satisfies(1.0.6, 2.3.0||<4.0.0, {"includePrelease":true,"loose":true,"rtl":true}) x 650,110 ops/sec ±0.64% (95 runs sampled)$ node benchmarks/bench-subset.jssubset(1.2.3, *) x 633,342 ops/sec ±0.61% (95 runs sampled)subset(^1.2.3, *) x 743,036 ops/sec ±0.47% (97 runs sampled)subset(^1.2.3-pre.0, *) x 680,087 ops/sec ±0.76% (98 runs sampled)subset(^1.2.3-pre.0, *) x 680,948 ops/sec ±0.46% (96 runs sampled)subset(1 || 2 || 3, *) x 330,669 ops/sec ±0.53% (98 runs sampled)```And after:```$ node benchmarks/bench-satisfies.jssatisfies(1.0.6, 1.0.3||^2.0.0) x 896,936 ops/sec ±0.53% (94 runs sampled)satisfies(1.0.6, 2.2.2||~3.0.0) x 998,214 ops/sec ±0.40% (95 runs sampled)satisfies(1.0.6, 2.3.0||<4.0.0) x 1,000,593 ops/sec ±0.43% (97 runs sampled)satisfies(1.0.6, 1.0.3||^2.0.0, {"includePrelease":true}) x 890,369 ops/sec ±0.41% (100 runs sampled)satisfies(1.0.6, 2.2.2||~3.0.0, {"includePrelease":true}) x 977,239 ops/sec ±0.48% (97 runs sampled)satisfies(1.0.6, 2.3.0||<4.0.0, {"includePrelease":true}) x 983,682 ops/sec ±0.95% (96 runs sampled)satisfies(1.0.6, 1.0.3||^2.0.0, {"includePrelease":true,"loose":true}) x 805,330 ops/sec ±0.84% (98 runs sampled)satisfies(1.0.6, 2.2.2||~3.0.0, {"includePrelease":true,"loose":true}) x 894,117 ops/sec ±0.43% (99 runs sampled)satisfies(1.0.6, 2.3.0||<4.0.0, {"includePrelease":true,"loose":true}) x 911,742 ops/sec ±0.42% (96 runs sampled)satisfies(1.0.6, 1.0.3||^2.0.0, {"includePrelease":true,"loose":true,"rtl":true}) x 741,254 ops/sec ±0.35% (97 runs sampled)satisfies(1.0.6, 2.2.2||~3.0.0, {"includePrelease":true,"loose":true,"rtl":true}) x 807,380 ops/sec ±0.42% (99 runs sampled)satisfies(1.0.6, 2.3.0||<4.0.0, {"includePrelease":true,"loose":true,"rtl":true}) x 820,390 ops/sec ±0.37% (99 runs sampled)$ node benchmarks/bench-subset.jssubset(1.2.3, *) x 905,030 ops/sec ±0.63% (96 runs sampled)subset(^1.2.3, *) x 1,026,457 ops/sec ±0.63% (95 runs sampled)subset(^1.2.3-pre.0, *) x 923,789 ops/sec ±0.41% (97 runs sampled)subset(^1.2.3-pre.0, *) x 923,136 ops/sec ±0.44% (96 runs sampled)subset(1 || 2 || 3, *) x 432,037 ops/sec ±0.67% (96 runs sampled)```
🤖 I have created a release *beep* *boop*---## [7.6.3](v7.6.2...v7.6.3)(2024-07-16)### Bug Fixes*[`73a3d79`](73a3d79)[#726](#726) optimize Rangeparsing and formatting (#726) (@jviide)### Documentation*[`2975ece`](2975ece)[#719](#719) fix extra backticktypo (#719) (@stdavis)---This PR was generated with [ReleasePlease](https://github.com/googleapis/release-please). See[documentation](https://github.com/googleapis/release-please#release-please).Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Loading
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:git diff v7.6.2...v7.6.3
Uh oh!
There was an error while loading.Please reload this page.