Skip to content

Use `let_it_be` in todos_finder_spec

Albert Salim requested to merge caalberts-todos-finder-spec-improvement into master

What does this MR do?

Use let_it_be in todos_finder_spec.rb to reduce factory calls.

Before:

FPROF=1 bundle exec spring rspec spec/finders/todos_finder_spec.rb
[TEST PROF INFO] Spring detected
Running via Spring preloader in process 73671
[TEST PROF INFO] Activating FPROF with `Spring.after_fork`
[TEST PROF INFO] FactoryProf enabled (simple mode)
[TEST PROF INFO] FactoryProf enabled (simple mode)
[TEST PROF INFO] No factories detected
Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}
.....................................

Finished in 26.03 seconds (files took 2.54 seconds to load)
37 examples, 0 failures

[TEST PROF INFO] Factories usage

 Total: 423
 Total top-level: 246
 Total time: 19.3981s
 Total uniq factories: 10

   total   top-level     total time      time per call      top-level time               name

      94          33       12.7034s            0.1351s             3.9075s            project
      79          79        9.6197s            0.1218s             9.6197s               todo
      68           0        2.3445s            0.0345s             0.0000s          namespace
      64          38        2.0224s            0.0316s             1.2857s               user
      51          29        5.1877s            0.1017s             1.1227s              issue
      39          39        1.3546s            0.0347s             1.3546s              group
      21          21        1.6927s            0.0806s             1.6927s      merge_request
       4           4        0.0708s            0.0177s             0.0708s              label
       2           2        0.3362s            0.1681s             0.3362s             design
       1           1        0.0083s            0.0083s             0.0083s            license

After:

FPROF=1 bundle exec spring rspec spec/finders/todos_finder_spec.rb
Running via Spring preloader in process 82730
[TEST PROF INFO] Activating FPROF with `Spring.after_fork`
[TEST PROF INFO] FactoryProf enabled (simple mode)
Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}
.....................................

Finished in 18.85 seconds (files took 2.54 seconds to load)
37 examples, 0 failures

[TEST PROF INFO] Factories usage

 Total: 260
 Total top-level: 113
 Total time: 14.4298s
 Total uniq factories: 10

   total   top-level     total time      time per call      top-level time               name

      78          78        9.1071s            0.1168s             9.1071s               todo
      67           8        9.2399s            0.1379s             1.0545s            project
      66           0        2.4793s            0.0376s             0.0000s          namespace
      28           7        4.0381s            0.1442s             0.5391s              issue
       7           6        0.3031s            0.0433s             0.2585s               user
       6           6        0.1174s            0.0196s             0.1174s              group
       4           4        0.1635s            0.0409s             0.1635s              label
       2           2        3.0109s            1.5055s             3.0109s      merge_request
       1           1        0.1660s            0.1660s             0.1660s             design
       1           1        0.0128s            0.0128s             0.0128s            license

Events (before): 10324 Events (after): 5881

Queries saved: 4443

Part of https://gitlab.com/gitlab-org/plan/-/issues/145

Edited by John Hope

Merge request reports