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

⚡️ Do not wrap stream when dropping 0 items #3552

Merged
merged 2 commits into from
Jan 15, 2023
Merged

Conversation

dubzzz
Copy link
Owner

@dubzzz dubzzz commented Jan 15, 2023

The previous implementation of Stream::drop was causing adding an unneeded wrapping level when asking to drop 0 items, while it could just have returned itself.

This PR attempts to drop this extra wrapping in order to check how impactful such removal could be.

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): ...

Sorry, something went wrong.

The previous implementation of `Stream::drop` was causing adding an unneeded wrapping level when asking to drop 0 items, while it could just have returned itself.

This PR attempts to drop this extra wrapping in order to check how impactful such removal could be.
@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 efa7966:

Sandbox Source
Vanilla Configuration
@fast-check/examples Configuration

@dubzzz
Copy link
Owner Author

dubzzz commented Jan 15, 2023

@codecov
Copy link

codecov bot commented Jan 15, 2023

Codecov Report

Merging #3552 (efa7966) into main (f213e00) will increase coverage by 0.00%.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #3552   +/-   ##
=======================================
  Coverage   95.47%   95.47%           
=======================================
  Files         213      213           
  Lines        5895     5897    +2     
  Branches     1094     1095    +1     
=======================================
+ Hits         5628     5630    +2     
  Misses        267      267           
Flag Coverage Δ
unit-tests 95.47% <ø> (+<0.01%) ⬆️
unit-tests-14.x-Linux 95.45% <ø> (-0.02%) ⬇️
unit-tests-16.x-Linux 95.45% <ø> (-0.02%) ⬇️
unit-tests-18.x-Linux 95.45% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/fast-check/src/stream/Stream.ts 100.00% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@dubzzz
Copy link
Owner Author

dubzzz commented Jan 15, 2023

Benchmark output:

Algorithm;3.5.0;main;extra
Property(fc.boolean());5617.185147968751;5297.471864315738;5553.427225813935
Property(fc.integer());5690.22454620953;5383.440453157618;5514.55369073599
Property(fc.maxSafeInteger());5573.382490209479;5329.093222093854;5385.804904894663
Property(fc.float());5333.816906223456;4900.883303947879;5224.31452811536
Property(fc.double());4229.024936735065;4014.582256594136;4290.844470469677
Property(fc.bigInt());1812.9687577334869;2049.664725308128;2091.57272322898
Property(fc.char());5669.646563878169;5402.796228317743;5761.984815416171
Property(fc.string());3109.0238158290817;2904.969537800367;2914.01932686125
Property(fc.string({ minLength: 0, maxLength: 500, size: 'max' }));193.72618742670417;196.38569176048424;195.8407060710256
Property(fc.string({ minLength: 0, maxLength: 25_000, size: 'max' }));3.1779909572791882;3.063773475698965;3.047401012654204
Property(fc.array(fc.integer()));3990.8851462469393;3635.1939072970868;3699.2318580123356
Property(fc.array(fc.integer(), { minLength: 0, maxLength: 500, size: 'max' }));301.76379501214154;302.2765288485371;315.003563936755
Property(fc.array(fc.integer(), { minLength: 0, maxLength: 25_000, size: 'max' }));5.573364840107314;5.639533411189106;5.41918576877696
Property(fc.uniqueArray(fc.integer()));3582.706448562175;3472.3976200801008;3505.257651168614
Property(fc.uniqueArray(fc.integer(), { minLength: 0, maxLength: 500, size:'max' }));197.38259949220432;202.21776840491015;207.9906459992232
Property(fc.anything());327.9339970719733;325.2515440938283;325.535768099741
Property(fc.constant('a'));6023.111844619028;5951.778048225678;6366.262892015691
Property(fc.constantFrom('a', 'b', 'c'));6369.507799022521;5878.037203108478;6055.13443377823
Property(fc.option(fc.integer()));5339.4746276345495;5278.858820650969;5736.088053375106
Property(fc.oneof(fc.ascii(), fc.hexa()));5446.265916548198;5253.175148334138;5604.285581918781
Property(fc.oneof(fc.ascii()@w=1, fc.hexa()@w=2));5311.696699147492;5061.983232964657;5472.596582281175
Property(fc.tuple(fc.ascii(), fc.hexa()));4681.1366753902;4280.288125901514;4411.040324378289
Property(fc.record({ascii: fc.ascii(), hexa: fc.hexa()}));2914.534505480107;2766.3927881404675;3256.1406598824437
Property(<tree-with-letrec>);3373.4370066303945;3301.8800571190086;3473.3587239921553
Property(<comment-generator-letrec>);1731.4412345045632;1688.4709404850469;1686.076184619751
Property(fc.emailAddress());58.83048457285896;58.67677623355856;59.16671318888066
Property(fc.webUrl());107.21318433383912;108.1799188489429;104.27505422258224
Property(fc.integer().filter(() => true));5282.111081278243;5394.587330366675;5487.039521773577
Property(fc.integer().map(n => n));5266.06044620981;5153.5108659189555;5454.147901122451
Property(fc.integer().chain(() => fc.integer()));5018.250162518229;4767.065034580982;5028.653673742715
Property(fc.integer().noBias());5989.380925705344;5767.860872972702;5761.1836447623655
Property(fc.integer().noShrink());5716.292198124118;5564.3845015388015;5707.121599647007

Algorithm;3.5.0;main;extra
Property(fc.boolean());+;=;+
Property(fc.integer());+;=;=
Property(fc.maxSafeInteger());+;=;=
Property(fc.float());+;=;+
Property(fc.double());+;=;+
Property(fc.bigInt());--;=;=
Property(fc.char());+;=;+
Property(fc.string());+;=;=
Property(fc.string({ minLength: 0, maxLength: 500, size: 'max' }));=;=;=
Property(fc.string({ minLength: 0, maxLength: 25_000, size: 'max' }));=;=;=
Property(fc.array(fc.integer()));+;=;=
Property(fc.array(fc.integer(), { minLength: 0, maxLength: 500, size: 'max' }));=;=;+
Property(fc.array(fc.integer(), { minLength: 0, maxLength: 25_000, size: 'max' }));=;=;=
Property(fc.uniqueArray(fc.integer()));+;=;=
Property(fc.uniqueArray(fc.integer(), { minLength: 0, maxLength: 500, size:'max' }));=;=;+
Property(fc.anything());=;=;=
Property(fc.constant('a'));=;=;+
Property(fc.constantFrom('a', 'b', 'c'));+;=;=
Property(fc.option(fc.integer()));=;=;+
Property(fc.oneof(fc.ascii(), fc.hexa()));+;=;+
Property(fc.oneof(fc.ascii()@w=1, fc.hexa()@w=2));+;=;+
Property(fc.tuple(fc.ascii(), fc.hexa()));+;=;=
Property(fc.record({ascii: fc.ascii(), hexa: fc.hexa()}));+;=;++
Property(<tree-with-letrec>);=;=;+
Property(<comment-generator-letrec>);=;=;=
Property(fc.emailAddress());=;=;=
Property(fc.webUrl());=;=;-
Property(fc.integer().filter(() => true));=;=;=
Property(fc.integer().map(n => n));=;=;+
Property(fc.integer().chain(() => fc.integer()));+;=;+
Property(fc.integer().noBias());+;=;=
Property(fc.integer().noShrink());+;=;+

@dubzzz dubzzz merged commit c1e6429 into main Jan 15, 2023
@dubzzz dubzzz deleted the attempt-stream-optim branch January 15, 2023 15:28
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