Benchmark Benchmark.ips do |bm| bm.report 'INDEX: Integration Test' do Minitest.run_one_method(IntegrationTest, 'test_index') end bm.report 'INDEX: Functional Test' do Minitest.run_one_method(ControllerTest, 'test_index') end bm.compare! end Controller Integration Compare
Controller Bottleneck Minitest.run_one_method(ControllerTest, 'test_index') StackProf.run(mode: :cpu, out: 'stackprof.dump') do 3000.times do Minitest.run_one_method(ControllerTest, 'test_index') end end
on_signal def self.on_signal name, action # :nodoc: supported = SIGNALS[name] old_trap = trap name do old_trap.call if old_trap.respond_to? :call action.call end if supported yield ensure trap name, old_trap if supported end
Time the process $ time ruby benchmark.rb real 0m12.358s user 0m11.732s sys 0m0.498s $ time ruby benchmark.rb real 0m12.055s user 0m11.462s sys 0m0.475s Before After
bin stub source code #!/Users/aaron/.rbenv/versions/ruby-trunk/bin/ruby # # This file was generated by RubyGems. # # The application 'bundler' is installed as part of a gem, and # this file is here to facilitate running it. # # some unimportant stuff happens here! gem 'bundler', version load Gem.bin_path('bundler', 'bundle', version)
allocations to require one file Number of allocations 0 22500 45000 67500 90000 Number of Gems on the system 0 100 200 300 400 500 600 700 800 900 1000 best worst
allocations to activate one gem Number of allocations 0 10000 20000 30000 40000 Number of Gems on the system 0 100 200 300 400 500 600 700 800 900 1000
`bundle exec` time Time in seconds 1.44 1.45 1.46 1.47 1.48 Number of gems in the gemfile 0 100 200 300 400 500 600 700 800 900 1000 y = 0.0008x + 1.4603 R² = 0.1323
`bundle update` time Time in Seconds 0 17.5 35 52.5 70 Number of Gems in the Gemfile 0 100 200 300 400 500 600 700 800 900 1000 y = 0.6984x2 - 2.9466x + 13.856 R² = 0.999
bin stub source code #!/Users/aaron/.rbenv/versions/ruby-trunk/bin/ruby # # This file was generated by RubyGems. # # The application 'bundler' is installed as part of a gem, and # this file is here to facilitate running it. # # some unimportant stuff happens here! gem 'bundler', version load Gem.bin_path('bundler', 'bundle', version) gem name