Speed-up API error tracking project settings specs
What does this MR do and why?
Speed-up API error tracking project settings specs
Assign roles only once in a before_all
block.
Speed up?
The overall speed up is small but it can be seen that After we are using less SQL queries (Total events: 1435
after vs Total events: 2082
before) because we are using add_X
only once in a before_all
block at the top.
Before
[TEST PROF INFO] RSpecDissect report
Total time: 00:08.676
Total `let` time: 00:00.244
Total `before(:each)` time: 00:02.423
Top 5 slowest suites (by `let` time):
API::ErrorTra...rojectSettings (./spec/requests/api/error_tracking/project_settings_spec.rb:5) – 00:00.244 of 00:08.676 (27)
↳ project – 49
↳ user – 49
↳ setting – 22
Top 5 slowest suites (by `before(:each)` time):
API::ErrorTra...rojectSettings (./spec/requests/api/error_tracking/project_settings_spec.rb:5) – 00:02.423 of 00:08.676 (27)
[TEST PROF INFO] FactoryDoctor says: "Looks good to me!"
[TEST PROF INFO] EventProf results for sql.active_record
Total time: 00:02.543 of 00:10.914 (23.31%)
Total events: 2082
Top 5 slowest suites (by time):
API::ErrorTra...rojectSettings (./spec/requests/api/error_tracking/project_settings_spec.rb:5) – 00:02.543 (2082 / 27) of 00:10.914 (23.31%)
Finished in 17.64 seconds (files took 1.81 seconds to load)
27 examples, 0 failures
Randomized with seed 47652
[TEST PROF INFO] Time spent in factories: 00:02.174 (10.98% of total time)
[TEST PROF INFO] Factories usage
Total: 34
Total top-level: 30
Total time: 00:02.174 (out of 00:20.322)
Total uniq factories: 6
total top-level total time time per call top-level time name
24 24 0.2471s 0.0103s 0.2471s personal_access_token
3 2 0.9426s 0.3142s 0.7079s project
3 0 0.2584s 0.0861s 0.0000s namespace
2 2 0.3030s 0.1515s 0.3030s project_error_tracking_setting
1 1 0.9093s 0.9093s 0.9093s user
1 1 0.0071s 0.0071s 0.0071s license
After
[TEST PROF INFO] RSpecDissect report
Total time: 00:06.794
Total `let` time: 00:00.001
Total `before(:each)` time: 00:00.457
Top 5 slowest suites (by `let` time):
API::ErrorTra...rojectSettings (./spec/requests/api/error_tracking/project_settings_spec.rb:5) – 00:00.001 of 00:06.794 (27)
↳ project – 27
↳ user – 27
↳ setting – 22
Top 5 slowest suites (by `before(:each)` time):
API::ErrorTra...rojectSettings (./spec/requests/api/error_tracking/project_settings_spec.rb:5) – 00:00.457 of 00:06.794 (27)
[TEST PROF INFO] FactoryDoctor says: "Looks good to me!"
[TEST PROF INFO] EventProf results for sql.active_record
Total time: 00:01.505 of 00:08.330 (18.08%)
Total events: 1435
Top 5 slowest suites (by time):
API::ErrorTra...rojectSettings (./spec/requests/api/error_tracking/project_settings_spec.rb:5) – 00:01.505 (1435 / 27) of 00:08.330 (18.08%)
Finished in 13.99 seconds (files took 2.33 seconds to load)
27 examples, 0 failures
Randomized with seed 47652
[TEST PROF INFO] Time spent in factories: 00:01.266 (7.58% of total time)
[TEST PROF INFO] Factories usage
Total: 33
Total top-level: 31
Total time: 00:01.266 (out of 00:17.112)
Total uniq factories: 6
total top-level total time time per call top-level time name
24 24 0.2559s 0.0107s 0.2559s personal_access_token
3 3 0.1542s 0.0514s 0.1542s user
2 2 0.8001s 0.4000s 0.8001s project
2 0 0.4009s 0.2004s 0.0000s namespace
1 1 0.0473s 0.0473s 0.0473s project_error_tracking_setting
1 1 0.0092s 0.0092s 0.0092s license
How to set up and validate locally
EVENT_PROF='sql.active_record' FPROF=1 bin/rspec spec/requests/api/error_tracking/project_settings_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