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

πŸ› Fix safeApply never calling original apply #3102

Merged
merged 2 commits into from
Aug 30, 2022
Merged

Conversation

dubzzz
Copy link
Owner

@dubzzz dubzzz commented Aug 30, 2022

Existing version of the code was wrong as it was expecting apply to be directly defined on the called function while in theory it comes from the Function.prototype.

Given benchmarks we did on https://github.com/dubzzz/fast-check-benchmarks/blob/main/benchmark-poisoning-results.txt, we expect some performance uplift from this change:

  • before: from 8,572.147 to 8,823.322 ops/sec
  • after: from 15,083.692 to 15,573.392 ops/sec

Measurements on fast-check itself will be carried out before merging the fix to make sure of the performance boost.

Category:

  • ✨ Introduce new features
  • πŸ“ Add or update documentation
  • βœ… Add or update tests
  • πŸ› Fix a bug
  • 🏷️ Add or update types
  • ⚑️ Improve performance
  • Other(s): ...

Potential impacts:

  • Generated values
  • Shrink values
  • Performance
  • Typings
  • Other(s): ...

Existing verson of the code was wrong as it was expecting `apply` to be directly defined on the called function while in theory it comes from the `Function.prototype`.

Given benchmarks we did on https://github.com/dubzzz/fast-check-benchmarks/blob/main/benchmark-poisoning-results.txt, we expect some performance uplift from this change:
- before: from 8,572.147 to 8,823.322 ops/sec
- after: from 15,083.692 to 15,573.392 ops/sec

Measurments on fast-check itself will be carried out before merging the fix to make sure of the performance boost.
@codesandbox-ci
Copy link

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 48d4cb5:

Sandbox Source
Vanilla Configuration
@fast-check/examples Configuration

@codesandbox-ci
Copy link

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 fdefee0:

Sandbox Source
Vanilla Configuration
@fast-check/examples Configuration

@dubzzz
Copy link
Owner Author

dubzzz commented Aug 30, 2022

Performance measurements for current main (dd5b27b) (aka main) vs 3.1.0 (aka 3.1.0) vs this PR (aka extra):

Algorithm 3.1.0 main extra
Property(fc.boolean()) 8429 ops/s 5430 ops/s 6481 ops/s
Property(fc.integer()) 7909 ops/s 5100 ops/s 6235 ops/s
Property(fc.maxSafeInteger()) 7227 ops/s 5078 ops/s 5927 ops/s
Property(fc.float()) 7126 ops/s 4872 ops/s 5652 ops/s
Property(fc.double()) 5343 ops/s 3761 ops/s 4298 ops/s
Property(fc.bigInt()) 2291 ops/s 1933 ops/s 2068 ops/s
Property(fc.char()) 7871 ops/s 4888 ops/s 6089 ops/s
Property(fc.string()) 3857 ops/s 1730 ops/s 2226 ops/s
Property(fc.string({ minLength: 0, maxLength: 500, size: 'max' })) 248 ops/s 73 ops/s 105 ops/s
Property(fc.string({ minLength: 0, maxLength: 25_000, size: 'max' })) 3 ops/s 1 ops/s 1 ops/s
Property(fc.array(fc.integer())) 5077 ops/s 2069 ops/s 2830 ops/s
Property(fc.array(fc.integer(), { minLength: 0, maxLength: 500, size: 'max' })) 374 ops/s 83 ops/s 124 ops/s
Property(fc.array(fc.integer(), { minLength: 0, maxLength: 25_000, size: 'max' })) 6 ops/s 1 ops/s 2 ops/s
Property(fc.uniqueArray(fc.integer())) 4456 ops/s 1707 ops/s 2321 ops/s
Property(fc.uniqueArray(fc.integer(), { minLength: 0, maxLength: 500, size:'max' })) 251 ops/s 61 ops/s 88 ops/s
Property(fc.anything()) 450 ops/s 222 ops/s 281 ops/s
Property(fc.constant('a')) 9264 ops/s 5931 ops/s 7111 ops/s
Property(fc.constantFrom('a', 'b', 'c')) 8974 ops/s 5822 ops/s 6872 ops/s
Property(fc.option(fc.integer())) 7483 ops/s 4711 ops/s 5690 ops/s
Property(fc.oneof(fc.ascii(), fc.hexa())) 6937 ops/s 4444 ops/s 5569 ops/s
Property(fc.oneof(fc.ascii()@w=1, fc.hexa()@w=2)) 6996 ops/s 4487 ops/s 5590 ops/s
Property(fc.tuple(fc.ascii(), fc.hexa())) 5852 ops/s 2905 ops/s 3828 ops/s
Property(fc.record({ascii: fc.ascii(), hexa: fc.hexa()})) 5250 ops/s 2230 ops/s 2502 ops/s
Property(<tree-with-letrec>) 4048 ops/s 2089 ops/s 2497 ops/s
Property(<comment-generator-letrec>) 2222 ops/s 1275 ops/s 1490 ops/s
Property(fc.emailAddress()) 71 ops/s 55 ops/s 61 ops/s
Property(fc.webUrl()) 129 ops/s 105 ops/s 109 ops/s
Property(fc.integer().filter(() => true)) 7655 ops/s 5008 ops/s 6128 ops/s
Property(fc.integer().map(n => n)) 7842 ops/s 4980 ops/s 6098 ops/s
Property(fc.integer().chain(() => fc.integer())) 6666 ops/s 4383 ops/s 4916 ops/s
Property(fc.integer().noBias()) 8592 ops/s 5374 ops/s 6822 ops/s
Property(fc.integer().noShrink()) 7807 ops/s 5063 ops/s 6208 ops/s

More details at: https://github.com/dubzzz/fast-check-benchmarks/runs/8103484316

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant