Class: Workarea::PerformanceTest
- Inherits:
-
ActionDispatch::IntegrationTest
- Object
- ActionDispatch::IntegrationTest
- Workarea::PerformanceTest
- Extended by:
- TestCase::Decoration
- Includes:
- Factories, IntegrationTest::Configuration, IntegrationTest::Locales, TestCase::Configuration, TestCase::Encryption, TestCase::Geocoder, TestCase::Locales, TestCase::RunnerLocation, TestCase::S3, TestCase::SearchIndexing, TestCase::Workers
- Defined in:
- lib/workarea/performance_test.rb
Constant Summary collapse
- HEADER =
%w(measurement created_at workarea rails ruby revision passed)
Instance Method Summary collapse
Methods included from TestCase::Decoration
Methods included from IntegrationTest::Locales
Methods included from IntegrationTest::Configuration
#set_current_admin, #set_current_user
Methods included from Factories
add, #create_admin_bookmark, #create_admin_visit, #create_audit_log_entry, #create_email_signup, #create_help_article, #create_inventory, #create_release, #create_shipping, #create_shipping_service, #create_shipping_sku, #create_tax_category, #create_tempfile, #factory_defaults, #factory_defaults_config, included, require_factories
Methods included from TestCase::Geocoder
#restore_geocoder_config, #save_geocoder_config
Methods included from TestCase::Encryption
#ensure_encryption_key, #reset_encryption_key
Methods included from TestCase::S3
#mock_s3, #mock_s3_cors_response, #reset_s3
Methods included from TestCase::Locales
#restore_locales, #save_locales, #set_locales
Methods included from TestCase::RunnerLocation
#running_from_source?, #running_in_dummy_app?, #running_in_gem?
Methods included from TestCase::Configuration
#reset_config_state, #store_config_state
Instance Method Details
#reset_caching ⇒ Object
29 30 31 |
# File 'lib/workarea/performance_test.rb', line 29 def reset_caching ActionController::Base.perform_caching = @controller_caching end |
#run ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/workarea/performance_test.rb', line 33 def run with_info_handler do time_it do capture_exceptions do pass && (return self) unless ENV['PERF_TEST'] =~ /true/ before_setup setup after_setup with_benchmarking { self.send self.name } end Minitest::Test::TEARDOWN_METHODS.each do |hook| capture_exceptions { self.send hook } end end end self # per contract end |
#warmup_app ⇒ Object
23 24 25 26 27 |
# File 'lib/workarea/performance_test.rb', line 23 def warmup_app @controller_caching = ActionController::Base.perform_caching ActionController::Base.perform_caching = true get '/' end |
#with_benchmarking(&block) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/workarea/performance_test.rb', line 55 def with_benchmarking(&block) result = Benchmark.measure { yield } previous_times = previous_run_measurements previous_times.each do |time| if time < result.real assert_in_epsilon( time, result.real, max_percentage_of_change, ) end end benchmark_file.puts(formatted_results(result)) rescue Minitest::Assertion => e benchmark_file.puts(formatted_results(result, false)) raise e ensure benchmark_file.close end |