Skip to content

Improve slow spec reducing factories

Arturo Herrero requested to merge 497336-improve-test into master

Description

This reduces the number of factories used in a slow spec. We are using Capybara, so the running time could vary from one execution to another, but this reduces the database factories, so we are probably improving the time spent running the spec.

Before

[TEST PROF INFO] Time spent in factories: 00:40.972 (4.3% of total time)
[TEST PROF INFO] Factories usage

 Total: 209
 Total top-level: 129
 Total time: 00:40.972 (out of 15:53.407)
 Total uniq factories: 21

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

   project                    21          21       20.7622s            0.9887s            20.7622s
   organization               21           0        0.2030s            0.0097s             0.0000s
   work_item_type             18           0        0.1602s            0.0089s             0.0000s
   note                       17          17        1.5902s            0.0935s             1.5902s
   text_diff_position         16           0        0.0063s            0.0004s             0.0000s
   user                       13           5        1.8139s            0.1395s             0.5949s
   issue                      10           9        1.2039s            0.1204s             1.1308s
   milestone                   9           9        0.2298s            0.0255s             0.2298s
   note_on_commit              8           8        0.5758s            0.0720s             0.5758s
   diff_note_on_commit         8           8        1.2236s            0.1530s             1.2236s
   merge_request_with_diffs        8           8        9.6827s            1.2103s             9.6827s
   discussion_note_on_merge_request        8           8        0.2189s            0.0274s             0.2189s
   diff_note_on_merge_request        8           8        1.6223s            0.2028s             1.6223s
   namespace_settings          8           0        0.0510s            0.0064s             0.0000s
   note_on_project_snippet        8           8        0.2045s            0.0256s             0.2045s
   namespace_ci_cd_settings        8           0        0.0262s            0.0033s             0.0000s
   group                       8           8        1.4208s            0.1776s             1.4208s
   work_item                   8           8        0.6117s            0.0765s             0.6117s
   license                     2           2        0.0223s            0.0111s             0.0223s
   zoekt_node                  1           1        0.0167s            0.0167s             0.0167s
   merge_request               1           1        1.0657s            1.0657s             1.0657s

After

[TEST PROF INFO] Time spent in factories: 00:30.998 (3.4% of total time)
[TEST PROF INFO] Factories usage

 Total: 197
 Total top-level: 117
 Total time: 00:30.998 (out of 15:13.155)
 Total uniq factories: 21

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

   organization               21           0        0.2458s            0.0117s             0.0000s
   work_item_type             18           0        0.1764s            0.0098s             0.0000s
   note                       17          17        1.7477s            0.1028s             1.7477s
   text_diff_position         16           0        0.0061s            0.0004s             0.0000s
   user                       13           5        1.7955s            0.1381s             0.6036s
   issue                      10           9        0.7462s            0.0746s             0.6755s
   milestone                   9           9        0.2137s            0.0237s             0.2137s
   project                     9           9       10.2378s            1.1375s            10.2378s
   diff_note_on_commit         8           8        1.2525s            0.1566s             1.2525s
   merge_request_with_diffs        8           8        9.9923s            1.2490s             9.9923s
   discussion_note_on_merge_request        8           8        0.2128s            0.0266s             0.2128s
   diff_note_on_merge_request        8           8        1.4761s            0.1845s             1.4761s
   group                       8           8        1.5727s            0.1966s             1.5727s
   note_on_project_snippet        8           8        0.2043s            0.0255s             0.2043s
   namespace_settings          8           0        0.0768s            0.0096s             0.0000s
   namespace_ci_cd_settings        8           0        0.0377s            0.0047s             0.0000s
   work_item                   8           8        1.0961s            0.1370s             1.0961s
   note_on_commit              8           8        0.6066s            0.0758s             0.6066s
   license                     2           2        0.0206s            0.0103s             0.0206s
   merge_request               1           1        1.0675s            1.0675s             1.0675s
   zoekt_node                  1           1        0.0191s            0.0191s             0.0191s

Related to #497336 (closed).

Merge request reports

Loading