Question: Measure speed of RSpec tests

Question

Measure speed of RSpec tests

Answers 1
Added at 2016-12-30 09:12
Tags
Question

Slow running tests are unwanted for obvious problems. But by default RSpec gives no indication about speed of individuals tests and gives only summary information.

How one may change this and get prfiling information allowing one to find tests responsible for slow running test suite?

Answers to

Measure speed of RSpec tests

nr: #1 dodano: 2016-12-30 09:12

use rspec --profile.

Example of output:

Top 10 slowest examples (911.59 seconds, 100.0% of total time):
  WordProcessor should normalize, synonimize and variantify
    874.29 seconds ./spec/word_processor_spec.rb:20
  Normalizer should return singular nominative masculine case (mianownik liczby pojedynczej, forma męska dla przymiotników) of phrases where every word may be normalized to singular nominative case (mianownik liczby pojedynczej)
    37.12 seconds ./spec/word_normalize_spec.rb:35
  VariantFinder should return singular nominative case (mianownik liczby pojedynczej) of complex phrases
    0.06575 seconds ./spec/word_find_all_variants_spec.rb:49
  Normalizer should return singular nominative masculine case (mianownik liczby pojedynczej, forma męska dla przymiotników) of phrases where transforming every word separately is not solution
    0.03283 seconds ./spec/word_normalize_spec.rb:44
  WordProcessor synonimize all produced variants
    0.02776 seconds ./spec/word_processor_spec.rb:49
  Synonym returns array of known synonyms
    0.02643 seconds ./spec/word_synonym_spec.rb:26
  VariantFinder should return all forms including singular nominative masculine case (mianownik liczby pojedynczej, forma męska dla przymiotników)
    0.00995 seconds ./spec/word_find_all_variants_spec.rb:10
  Synonym should allow more specified terms to be synonyms of general, but general not to be synonym of specific
    0.00924 seconds ./spec/word_synonym_spec.rb:48
  Normalizer should return singular nominative masculine case (mianownik liczby pojedynczej, forma męska dla przymiotników)
    0.00814 seconds ./spec/word_normalize_spec.rb:10
  VariantFinder should return all valid variants
    0.00319 seconds ./spec/word_find_all_variants_spec.rb:32

Top 5 slowest example groups:
  WordProcessor
    291.44 seconds average (874.31 seconds / 3 examples) ./spec/word_processor_spec.rb:4
  Normalizer
    7.43 seconds average (37.17 seconds / 5 examples) ./spec/word_normalize_spec.rb:4
  VariantFinder
    0.01222 seconds average (0.08556 seconds / 7 examples) ./spec/word_find_all_variants_spec.rb:4
  Synonym
    0.01005 seconds average (0.04018 seconds / 4 examples) ./spec/word_synonym_spec.rb:4
  RecipeSplitter
    0.0008 seconds average (0.00319 seconds / 4 examples) ./spec/recipe_splitter_spec.rb:6

Finished in 15 minutes 12 seconds (files took 0.30729 seconds to load)
23 examples, 0 failures, 2 pending

solution found at http://shuheikagawa.com/blog/2015/09/26/speed-up-your-rspec-tests-by-reviewing-factory-girl/

Source Show
◀ Wstecz