2016-12-30 67 views
0

慢速運行測試對於顯而易見的問題是不希望的。但是,默認情況下,RSpec不會提供有關個人測試速度的信息,只會給出摘要信息。RSpec測試的測量速度

如何改變這種情況並獲得prfiling信息,以便找到負責運行緩慢的測試套件的測試?

回答

3

使用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/