Speed up specs for EnvironmentStatus serializer
What does this MR do and why?
Use let_it_be
+ before_all
to reduce SQL queries.
This spec can be run in random order.
Contributes to &8745.
RSpec Profiling
Here's the output from test-prof
when run with FPROF=1
. Note:
-
Total amount
of factories created went down from 161 to 12🚀 -
Total events
went down from 5101 to 660 - Queries saved: 4441
Before
[TEST PROF INFO] Time spent in factories: 00:24.034 (69.33% of total time)
[TEST PROF INFO] Factories usage
Total: 161
Total top-level: 49
Total time: 00:24.034 (out of 00:38.689)
Total uniq factories: 9
total top-level total time time per call top-level time name
32 0 18.1921s 0.5685s 0.0000s project
32 0 3.3282s 0.1040s 0.0000s namespace
16 16 11.3230s 0.7077s 11.3230s deployment
16 0 9.7281s 0.6080s 0.0000s environment
16 0 0.3727s 0.0233s 0.0000s ci_pipeline
16 0 0.7212s 0.0451s 0.0000s ci_build
16 16 11.4436s 0.7152s 11.4436s merge_request
16 16 1.2524s 0.0783s 1.2524s user
1 1 0.0156s 0.0156s 0.0156s license
After
[TEST PROF INFO] Time spent in factories: 00:02.621 (20.01% of total time)
[TEST PROF INFO] Factories usage
Total: 12
Total top-level: 5
Total time: 00:02.621 (out of 00:17.008)
Total uniq factories: 9
total top-level total time time per call top-level time name
2 2 0.5891s 0.2946s 0.5891s user
2 0 1.4486s 0.7243s 0.0000s project
2 0 0.1742s 0.0871s 0.0000s namespace
1 1 0.0123s 0.0123s 0.0123s license
1 1 1.2511s 1.2511s 1.2511s deployment
1 0 1.0112s 1.0112s 0.0000s environment
1 0 0.0733s 0.0733s 0.0000s ci_pipeline
1 0 0.1167s 0.1167s 0.0000s ci_build
1 1 0.7689s 0.7689s 0.7689s merge_request
How to set up and validate locally
bin/rspec ./spec/serializers/environment_status_entity_spec.rb
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