Skip to content

Instantly share code, notes, and snippets.

@tgxworld
Last active August 29, 2015 14:03
Show Gist options
  • Save tgxworld/27d10b42805308ac7893 to your computer and use it in GitHub Desktop.
Save tgxworld/27d10b42805308ac7893 to your computer and use it in GitHub Desktop.
Comparison between Controller and Integration tests for https://github.com/fxn/rails-contributors
guoxiang@guoxiang-GS60-2PC-Ghost rails-contributors (integration) $ time for i in {1..100}; do rake test:controllers; done >> integration.txt
real 2m56.749s
user 2m37.466s
sys 0m15.781s
guoxiang@guoxiang-GS60-2PC-Ghost rails-contributors (integration) $ time for i in {1..100}; do rake test:controllers; done >> controller.txt
real 2m57.044s
user 2m37.664s
sys 0m15.830s
guoxiang@guoxiang-GS60-2PC-Ghost rails-contributors (integration) $ ruby time.rb
Total time for 100 runs of Integration Test: 57.89166599999998
Total time for 100 runs of Controller Test: 57.908929
Average time for 100 runs of Integration Test: 0.5789166599999997
Average time for 100 runs of Controller Test: 0.57908929
guoxiang@guoxiang-GS60-2PC-Ghost rails-contributors (integration) $ time for i in {1..100}; do rake test:controllers; done >> integration_log.txt
real 3m1.744s
user 2m42.044s
sys 0m16.227s
guoxiang@guoxiang-GS60-2PC-Ghost rails-contributors (integration) $ time for i in {1..100}; do rake test:controllers; done >> controller_log.txt
real 3m1.425s
user 2m41.728s
sys 0m16.214s
guoxiang@guoxiang-GS60-2PC-Ghost rails-contributors (integration) $ ruby time.rb
Total time for 100 runs of Integration Test: 54.335617000000006
Total time for 100 runs of Controller Test: 54.67934200000002
Average time for 100 runs of Integration Test: 0.54335617
Average time for 100 runs of Controller Test: 0.5467934200000002
integration = []
File.open('/home/guoxiang/work/rails-contributors/integration.txt', 'r').each_line do |line|
line.match(/Finished in ([\d.]+)/)
integration << $1.to_f if $1
end
functional = []
File.open('/home/guoxiang/work/rails-contributors/controller.txt', 'r').each_line do |line|
line.match(/Finished in ([\d.]+)/)
functional << $1.to_f if $1
end
integration_sum = integration.inject(:+)
functional_sum = functional.inject(:+)
integration_average = integration.inject(0.0) { |sum, n| sum + n } / integration.size
functional_average = functional.inject(0.0) { |sum, n| sum + n } / functional.size
puts "Total time for 100 runs of Integration Test: #{integration_sum}"
puts "Total time for 100 runs of Controller Test: #{functional_sum}"
puts "Average time for 100 runs of Integration Test: #{integration_average}"
puts "Average time for 100 runs of Controller Test: #{functional_average}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment