Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only run expensive setup where needed in Proquest spec #2117

Merged
merged 1 commit into from
Mar 12, 2021

Conversation

mark-dce
Copy link
Contributor

@mark-dce mark-dce commented Mar 11, 2021

There is some very expensive workflow and sample datea setup
in the Proquest spec that was being run for every test,
even where it wasn't needed.

This PR moves that setup to only the scoped tests that absolutely
require it. The PR also uses RSpec's :aggregate_failures feature
to group mulitple small examples into the same test so that fewer
total factory objects need to be created (also somewhat expensive).

There is some very expensive workflow and sample datea setup
in the Proquest spec that was being run for every test,
even where it wasn't needed.

This PR moves that setup to only the scoped tests that absolutely
require it.  The PR also uses RSpec's :aggregage_failures feature
to group mulitple small examples into the same test so that fewer
total factory objects need to be created (also somewhat expensive).
@mark-dce
Copy link
Contributor Author

Before and after timings - you can seen how a bunch of tests went down from >10s to <2s by removing the unneeded test setup for those examples. From 6m 52s down to 2m 2s! Note that there's no change in coverage: 71.25%.

BEFORE

% RUBYOPT="-W0" bundle exec rspec --profile 25 ./spec/models/proquest_behaviors_etd_spec.rb

Randomized with seed 64821
.............*.......

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) Etd ProQuest submission exports valid ProQuest XML
     # DTD validation seems to be broken in nokogiri
     # ./spec/models/proquest_behaviors_etd_spec.rb:35


Top 21 slowest examples (411.59 seconds, 100.0% of total time):
  Etd ProQuest submission gets the page count of the primary PDF
    30.48 seconds ./spec/models/proquest_behaviors_etd_spec.rb:51
  Etd ProQuest submission exporting packages zips the exported directory
    28.68 seconds ./spec/models/proquest_behaviors_etd_spec.rb:67
  Etd ProQuest submission names data file according to ProQuest specs
    27.28 seconds ./spec/models/proquest_behaviors_etd_spec.rb:60
  Etd ProQuest submission starts export package with upload_
    27.01 seconds ./spec/models/proquest_behaviors_etd_spec.rb:57
  Etd ProQuest submission names the supplemental files dir as directed
    27.01 seconds ./spec/models/proquest_behaviors_etd_spec.rb:63
  Etd ProQuest submission exports well formed XML
    26.87 seconds ./spec/models/proquest_behaviors_etd_spec.rb:43
  Etd ProQuest submission gets the primary pdf filename
    26.84 seconds ./spec/models/proquest_behaviors_etd_spec.rb:54
  Etd ProQuest submission exports valid ProQuest XML
    25.43 seconds ./spec/models/proquest_behaviors_etd_spec.rb:35
  Etd ProQuest research field associates research codes
    20.8 seconds ./spec/models/proquest_behaviors_etd_spec.rb:147
  Etd registrar data can load registrar data from a configurable location
    19.86 seconds ./spec/models/proquest_behaviors_etd_spec.rb:155
  Etd proquest submission type returns either 'masters' or 'doctoral'
    17.1 seconds ./spec/models/proquest_behaviors_etd_spec.rb:132
  Etd proquest embargo codes no embargo
    14.77 seconds ./spec/models/proquest_behaviors_etd_spec.rb:78
  Etd abstract formatting transforms tinymce output into something proquest can handle
    14 seconds ./spec/models/proquest_behaviors_etd_spec.rb:101
  Etd proquest submission records the date the etd was submitted to proquest
    13.84 seconds ./spec/models/proquest_behaviors_etd_spec.rb:167
  Etd Language codes transforms a language string into a ProQuest expected language code
    13.67 seconds ./spec/models/proquest_behaviors_etd_spec.rb:121
  Etd proquest embargo codes 6 years
    13.42 seconds ./spec/models/proquest_behaviors_etd_spec.rb:94
  Etd proquest embargo codes 1 year
    13.37 seconds ./spec/models/proquest_behaviors_etd_spec.rb:86
  Etd proquest embargo codes 6 months
    13.15 seconds ./spec/models/proquest_behaviors_etd_spec.rb:82
  Etd proquest embargo codes 2 years
    13.04 seconds ./spec/models/proquest_behaviors_etd_spec.rb:90
  Etd DISS_accept_date formats the degree awarded date as expected
    12.64 seconds ./spec/models/proquest_behaviors_etd_spec.rb:141
  Etd proquest submission allows the student to choose whether to submit
    12.33 seconds ./spec/models/proquest_behaviors_etd_spec.rb:162

Finished in 6 minutes 52 seconds (files took 17.49 seconds to load)
21 examples, 0 failures, 1 pending

Randomized with seed 64821

Coverage report generated for RSpec to /Users/mark/_no_backup_/Projects/laevigata/coverage. 1410 / 1979 LOC (71.25%) covered.

AFTER

% RUBYOPT="-W0" bundle exec rspec --profile 25 ./spec/models/proquest_behaviors_etd_spec.rb

Randomized with seed 61008
........*....

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) Etd ProQuest submission exports valid ProQuest XML
     # DTD validation seems to be broken in nokogiri
     # ./spec/models/proquest_behaviors_etd_spec.rb:35


Top 13 slowest examples (121.62 seconds, 99.9% of total time):
  Etd ProQuest submission exports well formed XML
    27.58 seconds ./spec/models/proquest_behaviors_etd_spec.rb:43
  Etd ProQuest submission returns valid required submission settings
    26.42 seconds ./spec/models/proquest_behaviors_etd_spec.rb:51
  Etd ProQuest submission exports valid ProQuest XML
    24.38 seconds ./spec/models/proquest_behaviors_etd_spec.rb:35
  Etd ProQuest submission exporting packages zips the exported directory
    23.51 seconds ./spec/models/proquest_behaviors_etd_spec.rb:59
  Etd proquest submission type returns either 'masters' or 'doctoral'
    5.31 seconds ./spec/models/proquest_behaviors_etd_spec.rb:116
  Etd Language codes transforms a language string into a ProQuest expected language code
    2.28 seconds ./spec/models/proquest_behaviors_etd_spec.rb:105
  Etd abstract formatting transforms tinymce output into something proquest can handle
    2.07 seconds ./spec/models/proquest_behaviors_etd_spec.rb:85
  Etd DISS_accept_date formats the degree awarded date as expected
    2.07 seconds ./spec/models/proquest_behaviors_etd_spec.rb:125
  Etd registrar data can load registrar data from a configurable location
    1.89 seconds ./spec/models/proquest_behaviors_etd_spec.rb:139
  Etd ProQuest research field associates research codes
    1.88 seconds ./spec/models/proquest_behaviors_etd_spec.rb:131
  Etd proquest submission allows the student to choose whether to submit
    1.57 seconds ./spec/models/proquest_behaviors_etd_spec.rb:146
  Etd proquest submission records the date the etd was submitted to proquest
    1.34 seconds ./spec/models/proquest_behaviors_etd_spec.rb:151
  Etd Embargo codes transforms an embargo_length into a ProQuest embargo code
    1.32 seconds ./spec/models/proquest_behaviors_etd_spec.rb:70

Finished in 2 minutes 1.7 seconds (files took 17.56 seconds to load)
13 examples, 0 failures, 1 pending

Randomized with seed 61008

Coverage report generated for RSpec to /Users/mark/_no_backup_/Projects/laevigata/coverage. 1410 / 1979 LOC (71.25%) covered.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 92.138% when pulling 9dce383 on faster-proquest-spec into 82d1fac on main.

@mark-dce mark-dce merged commit 7b65ef2 into main Mar 12, 2021
@mark-dce mark-dce deleted the faster-proquest-spec branch March 12, 2021 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants