-
-
Notifications
You must be signed in to change notification settings - Fork 181
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
faster string builder #5243
faster string builder #5243
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 014f110:
|
👋 A preview of the new documentation is available at: http://66ccba1564f43f44d69fc04d--dubzzz-fast-check.netlify.app |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5243 +/- ##
==========================================
- Coverage 95.32% 95.28% -0.04%
==========================================
Files 234 234
Lines 10414 10454 +40
Branches 2774 2789 +15
==========================================
+ Hits 9927 9961 +34
- Misses 487 493 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Quick stats from https://github.com/dubzzz/fast-check-benchmarks/actions/runs/10564220421/job/29266137622: │ 36 │ 'Property(fc.string()) on [email protected]' │ '4,304' │ 232288.18999661598 │ '±7.93%' │ 100 │
│ 37 │ 'Property(fc.string()) on fast-check@main' │ '4,572' │ 218695.099997567 │ '±9.12%' │ 100 │
│ 38 │ 'Property(fc.string()) on fast-check@extra' │ '4,120' │ 242704.4000022579 │ '±8.46%' │ 100 │
│ 39 │ '—' │ '—' │ '—' │ '—' │ '—' │
│ 40 │ "Property(fc.string({ minLength: 0, maxLength: 500, size: 'max' })) on [email protected]" │ '361' │ 2762602.10000386 │ '±2.11%' │ 100 │
│ 41 │ "Property(fc.string({ minLength: 0, maxLength: 500, size: 'max' })) on fast-check@main" │ '350' │ 2855386.4800039446 │ '±3.40%' │ 100 │
│ 42 │ "Property(fc.string({ minLength: 0, maxLength: 500, size: 'max' })) on fast-check@extra" │ '356' │ 2806718.819999369 │ '±2.35%' │ 100 │
│ 43 │ '—' │ '—' │ '—' │ '—' │ '—' │
│ 44 │ "Property(fc.string({ minLength: 0, maxLength: 25_000, size: 'max' })) on [email protected]" │ '5' │ 180600766.5200025 │ '±2.53%' │ 100 │
│ 45 │ "Property(fc.string({ minLength: 0, maxLength: 25_000, size: 'max' })) on fast-check@main" │ '5' │ 179889561.0000007 │ '±2.63%' │ 100 │
│ 46 │ "Property(fc.string({ minLength: 0, maxLength: 25_000, size: 'max' })) on fast-check@extra" │ '5' │ 178884024.72000045 │ '±2.69%' │ 100 │
│ 47 │ '—' │ '—' │ '—' │ '—' │ '—' │
│ 48 │ "Property(fc.string({ unit:'grapheme-composite' })) on [email protected]" │ '1,713' │ 583576.9199987408 │ '±7.69%' │ 100 │
│ 49 │ "Property(fc.string({ unit:'grapheme-composite' })) on fast-check@main" │ '1,934' │ 516992.73999780416 │ '±4.49%' │ 100 │
│ 50 │ "Property(fc.string({ unit:'grapheme-composite' })) on fast-check@extra" │ '4,029' │ 248156.24000213575 │ '±6.82%' │ 100 │
│ 51 │ '—' │ '—' │ '—' │ '—' │ '—' │
│ 52 │ "Property(fc.string({ unit:'grapheme-composite', minLength: 0, maxLength: 500, size: 'max' })) on [email protected]" │ '60' │ 16404330.040003989 │ '±1.82%' │ 100 │
│ 53 │ "Property(fc.string({ unit:'grapheme-composite', minLength: 0, maxLength: 500, size: 'max' })) on fast-check@main" │ '61' │ 16215262.000004295 │ '±1.58%' │ 100 │
│ 54 │ "Property(fc.string({ unit:'grapheme-composite', minLength: 0, maxLength: 500, size: 'max' })) on fast-check@extra" │ '299' │ 3341904.8900000053 │ '±2.57%' │ 100 │
│ 55 │ '—' │ '—' │ '—' │ '—' │ '—' │
│ 56 │ "Property(fc.string({ unit:'grapheme-composite', minLength: 0, maxLength: 25_000, size: 'max' })) on [email protected]" │ '1' │ 872918943.4099983 │ '±1.64%' │ 100 │
│ 57 │ "Property(fc.string({ unit:'grapheme-composite', minLength: 0, maxLength: 25_000, size: 'max' })) on fast-check@main" │ '1' │ 875319785.1599997 │ '±1.62%' │ 100 │
│ 58 │ "Property(fc.string({ unit:'grapheme-composite', minLength: 0, maxLength: 25_000, size: 'max' })) on fast-check@extra" │ '4' │ 219242737.48000735 │ '±2.37%' │ 100 │
│ 59 │ '—' │ '—' │ '—' │ '—' │ '—' │
│ 60 │ "Property(fc.string({ unit:'grapheme' })) on [email protected]" │ '1,487' │ 672319.1400012001 │ '±11.26%' │ 100 │
│ 61 │ "Property(fc.string({ unit:'grapheme' })) on fast-check@main" │ '1,699' │ 588359.929996077 │ '±7.26%' │ 100 │
│ 62 │ "Property(fc.string({ unit:'grapheme' })) on fast-check@extra" │ '3,713' │ 269276.8099962268 │ '±11.53%' │ 100 │
│ 63 │ '—' │ '—' │ '—' │ '—' │ '—' │
│ 64 │ "Property(fc.string({ unit:'grapheme', minLength: 0, maxLength: 500, size: 'max' })) on [email protected]" │ '58' │ 17055338.280001886 │ '±1.37%' │ 100 │
│ 65 │ "Property(fc.string({ unit:'grapheme', minLength: 0, maxLength: 500, size: 'max' })) on fast-check@main" │ '58' │ 17030465.200002074 │ '±1.75%' │ 100 │
│ 66 │ "Property(fc.string({ unit:'grapheme', minLength: 0, maxLength: 500, size: 'max' })) on fast-check@extra" │ '299' │ 3340003.819995327 │ '±2.51%' │ 100 │
│ 67 │ '—' │ '—' │ '—' │ '—' │ '—' │
│ 68 │ "Property(fc.string({ unit:'grapheme', minLength: 0, maxLength: 25_000, size: 'max' })) on [email protected]" │ '1' │ 906985892.3500043 │ '±1.56%' │ 100 │
│ 69 │ "Property(fc.string({ unit:'grapheme', minLength: 0, maxLength: 25_000, size: 'max' })) on fast-check@main" │ '1' │ 909319767.740001 │ '±1.53%' │ 100 │
│ 70 │ "Property(fc.string({ unit:'grapheme', minLength: 0, maxLength: 25_000, size: 'max' })) on fast-check@extra" │ '4' │ 216915173.79000086 │ '±2.12%' │ 100 │ |
**Description** <!-- Please provide a short description and potentially linked issues justifying the need for this PR --> The arbitrary `mapToConstant` used to rely on a linear scan to get the entry to be used to generate the element. It used to be sub-optimal for cases implying several entries (a normal scenario for this arbitrary). Our new implementation relies on a dichotomic-lookup that will be way less costly to execute. This change should have a visible impact when generating strings using the `string` arbitrary. Supersede #5243 <!-- * Your PR is fixing a bug or regression? Check for existing issues related to this bug and link them --> <!-- * Your PR is adding a new feature? Make sure there is a related issue or discussion attached to it --> <!-- You can provide any additional context to help into understanding what's this PR is attempting to solve: reproduction of a bug, code snippets... --> **Checklist** — _Don't delete this checklist and make sure you do the following before opening the PR_ - [x] The name of my PR follows [gitmoji](https://gitmoji.dev/) specification - [x] My PR references one of several related issues (if any) - [x] New features or breaking changes must come with an associated Issue or Discussion - [x] My PR does not add any new dependency without an associated Issue or Discussion - [x] My PR includes bumps details, please run `yarn bump` and flag the impacts properly - [x] My PR adds relevant tests and they would have failed without my PR (when applicable) <!-- More about contributing at https://github.com/dubzzz/fast-check/blob/main/CONTRIBUTING.md --> **Advanced** <!-- How to fill the advanced section is detailed below! --> - [x] Category: ⚡️ Improve performance - [x] Impacts: Faster `mapToConstant` but also any arbitrary derived from it: `string` and many others <!-- [Category] Please use one of the categories below, it will help us into better understanding the urgency of the PR --> <!-- * ✨ Introduce new features --> <!-- * 📝 Add or update documentation --> <!-- * ✅ Add or update tests --> <!-- * 🐛 Fix a bug --> <!-- * 🏷️ Add or update types --> <!-- * ⚡️ Improve performance --> <!-- * _Other(s):_ ... --> <!-- [Impacts] Please provide a comma separated list of the potential impacts that might be introduced by this change --> <!-- * Generated values: Can your change impact any of the existing generators in terms of generated values, if so which ones? when? --> <!-- * Shrink values: Can your change impact any of the existing generators in terms of shrink values, if so which ones? when? --> <!-- * Performance: Can it require some typings changes on user side? Please give more details --> <!-- * Typings: Is there a potential performance impact? In which cases? -->
Description
Checklist — Don't delete this checklist and make sure you do the following before opening the PR
yarn bump
and flag the impacts properlyAdvanced