对于明显的问题,慢速运行测试是不可取的。但是默认情况下,RSpec没有给出关于个人测试速度的指示,只给出了摘要信息。
如何改变这一点并获取prfiling信息,以便找到负责慢速运行测试套件的测试?
答案 0 :(得分:8)
使用rspec --profile
。
输出示例:
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
在http://shuheikagawa.com/blog/2015/09/26/speed-up-your-rspec-tests-by-reviewing-factory-girl/
找到解决方案