Last active
December 15, 2015 17:49
-
-
Save murbanski/5299475 to your computer and use it in GitHub Desktop.
Revisions
-
murbanski revised this gist
Apr 3, 2013 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,8 @@ RSpec.configure do |config| config.after(:suite) do STDERR.puts Hash[$factories_speed.sort_by { |k, v| v[:duration] }.reverse] total_duration = $factories_speed.sum {|k, v| v[:duration] } STDERR.puts "Total FactoryGirl duration: #{total_duration}" end end -
murbanski created this gist
Apr 3, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ require 'rspec/rails' # ... $factories_speed = Hash.new {|h, k| h[k] = {calls: 0, duration: 0} } ActiveSupport::Notifications.subscribe("factory_girl.run_factory") do |*args| event = ActiveSupport::Notifications::Event.new(*args) key = "#{event.payload[:strategy]}_#{event.payload[:name]}" $factories_speed[key][:calls] += 1 $factories_speed[key][:duration] += event.duration end RSpec.configure do |config| config.after(:suite) do STDERR.puts Hash[$factories_speed.sort_by { |k, v| v[:duration] }.reverse] end end