Draft: Speed up vulnerability presenter specs by using `build_stubbed`
What does this MR do and why?
This MR replaces the use of create
with build_stubbed
to improve spec performance.
The only factory create left to create a license for Enterprise Edition.
We went from
[TEST PROF INFO] Time spent in factories: 00:10.050 (54.16% of total time)
to
[TEST PROF INFO] Time spent in factories: 00:00.009 (0.07% of total time)
RSpec Profiling
Here's the output from test-prof
when run with FPROF=1
. Note:
-
Total amount
of factories created went down from 158 to 1🚀 -
Total events
went down from 3477 to 138 - Queries saved: 3339
Before
Finished in 18.89 seconds (files took 6.94 seconds to load)
16 examples, 0 failures
[TEST PROF INFO] Time spent in factories: 00:10.671 (54.71% of total time)
[TEST PROF INFO] Factories usage
Total: 158
Total top-level: 17
Total time: 00:10.671 (out of 00:23.966)
Total uniq factories: 10
total top-level total time time per call top-level time name
30 1 8.2825s 0.2761s 0.8936s project
30 0 3.1154s 0.1038s 0.0000s namespace
14 1 0.1837s 0.0131s 0.0512s ci_pipeline
14 14 9.7175s 0.6941s 9.7175s vulnerabilities_finding
14 0 4.0594s 0.2900s 0.0000s vulnerabilities_identifier
14 0 3.5583s 0.2542s 0.0000s vulnerabilities_scanner
14 0 1.5454s 0.1104s 0.0000s vulnerability
14 0 1.0691s 0.0764s 0.0000s author
13 0 0.0828s 0.0064s 0.0000s vulnerabilities_finding_pipeline
1 1 0.0094s 0.0094s 0.0094s license
After
Finished in 12.85 seconds (files took 7.15 seconds to load)
16 examples, 0 failures
Randomized with seed 28838
[TEST PROF INFO] Time spent in factories: 00:00.014 (0.11% of total time)
[TEST PROF INFO] Factories usage
Total: 1
Total top-level: 1
Total time: 00:00.014 (out of 00:18.088)
Total uniq factories: 1
total top-level total time time per call top-level time name
1 1 0.0150s 0.0150s 0.0150s license
Refs
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Peter Leitzen