Speed up banzai milestone reference filter specs
What does this MR do?
This MR improves the performance of bazai milestone reference filter specs by using let_it_be
.
Related to &3752.
Contributes to https://gitlab.com/gitlab-org/plan/-/issues/145.
Here's the output from test-prof
when run with FPROF=1
. Note:
-
Total
amount of factories created went down from 771 to 40🚀 -
Total events
went down from 14171 to 2259 - Queries saved: 11912
Before
[TEST PROF INFO] EventProf results for sql.active_record
Total time: 00:25.496 of 00:52.190 (48.85%)
Total events: 14171
Top 5 slowest suites (by time):
Banzai::Filte...eferenceFilter (./spec/lib/banzai/filter/milestone_reference_filter_spec.rb:5) – 00:25.496 (14171 / 131) of 00:52.190 (48.85%)
Finished in 57.63 seconds (files took 3.86 seconds to load)
131 examples, 0 failures
[TEST PROF INFO] Factories usage
Total: 771
Total top-level: 539
Total time: 47.6946s
Total uniq factories: 6
total top-level total time time per call top-level time name
227 227 8.6932s 0.0383s 8.6932s group
156 156 32.0381s 0.2054s 32.0381s project
140 24 8.4696s 0.0605s 1.8312s namespace
131 131 5.1158s 0.0391s 5.1158s milestone
116 0 5.6453s 0.0487s 0.0000s user
1 1 0.0164s 0.0164s 0.0164s license
After
[TEST PROF INFO] EventProf results for sql.active_record
Total time: 00:03.619 of 00:08.929 (40.53%)
Total events: 2259
Top 5 slowest suites (by time):
Banzai::Filte...eferenceFilter (./spec/lib/banzai/filter/milestone_reference_filter_spec.rb:5) – 00:03.619 (2259 / 131) of 00:08.929 (40.53%)
Finished in 14.33 seconds (files took 3.9 seconds to load)
131 examples, 0 failures
[TEST PROF INFO] Factories usage
Total: 40
Total top-level: 34
Total time: 3.2971s
Total uniq factories: 6
total top-level total time time per call top-level time name
15 15 0.6101s 0.0407s 0.6101s milestone
9 9 0.8315s 0.0924s 0.8315s group
8 8 1.8061s 0.2258s 1.8061s project
4 1 0.4131s 0.1033s 0.0365s namespace
3 0 0.1152s 0.0384s 0.0000s user
1 1 0.0131s 0.0131s 0.0131s license
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
- [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Peter Leitzen