Skip to content

Use array_pop() instead of array_shift() for processing Test objects in TestSuite::run() and optimize TestSuite::isEmpty()#5877

Merged
sebastianbergmann merged 2 commits intosebastianbergmann:10.5from
mvorisek:improve_array_pop
Jun 20, 2024
Merged

Use array_pop() instead of array_shift() for processing Test objects in TestSuite::run() and optimize TestSuite::isEmpty()#5877
sebastianbergmann merged 2 commits intosebastianbergmann:10.5from
mvorisek:improve_array_pop

Conversation

@mvorisek
Copy link
Copy Markdown
Contributor

improve #5875 performance, array_shift is very slow with large arrays

@sebastianbergmann sebastianbergmann added feature/test-runner CLI test runner type/performance Issues related to resource consumption (time and memory) labels Jun 20, 2024
@mvorisek mvorisek force-pushed the improve_array_pop branch from 0d34397 to 1267e41 Compare June 20, 2024 08:17
@mvorisek mvorisek marked this pull request as ready for review June 20, 2024 08:21
@mvorisek mvorisek force-pushed the improve_array_pop branch from 1267e41 to 47449ae Compare June 20, 2024 08:23
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.16%. Comparing base (1282659) to head (47449ae).

Additional details and impacted files
@@            Coverage Diff            @@
##               10.5    #5877   +/-   ##
=========================================
  Coverage     92.15%   92.16%           
- Complexity     6358     6360    +2     
=========================================
  Files           677      677           
  Lines         19270    19274    +4     
=========================================
+ Hits          17759    17763    +4     
  Misses         1511     1511           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sebastianbergmann
Copy link
Copy Markdown
Owner

improve #5875 performance, array_shift is very slow with large arrays

Can you share a benchmark? Thanks!

@mvorisek
Copy link
Copy Markdown
Contributor Author

https://3v4l.org/4vGK2/rfc#vgit.master_jit - with even more items the performance difference is even much higher - one has O(N) complexity as the array is always reallocated, the other one has O(1)

@sebastianbergmann sebastianbergmann changed the title Optimize TestSuite run with many providers Use array_pop() instead of array_shift() for processing Test objects in TestSuite::run() Jun 20, 2024
@sebastianbergmann sebastianbergmann changed the title Use array_pop() instead of array_shift() for processing Test objects in TestSuite::run() Use array_pop() instead of array_shift() for processing Test objects in TestSuite::run() and optimize TestSuite::empty() Jun 20, 2024
@sebastianbergmann sebastianbergmann changed the title Use array_pop() instead of array_shift() for processing Test objects in TestSuite::run() and optimize TestSuite::empty() Use array_pop() instead of array_shift() for processing Test objects in TestSuite::run() and optimize TestSuite::isEmpty() Jun 20, 2024
@sebastianbergmann sebastianbergmann merged commit 3a664ca into sebastianbergmann:10.5 Jun 20, 2024
@sebastianbergmann
Copy link
Copy Markdown
Owner

Thank you!

@mvorisek mvorisek deleted the improve_array_pop branch June 20, 2024 09:10
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

feature/test-runner CLI test runner type/performance Issues related to resource consumption (time and memory)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants