Skip to content

Loading…

#4938 Fix launching performance tests #7416

Closed
wants to merge 1 commit into from

4 participants

@route

When we run rake test:benchmark for performance tests it raises
ArgumentError that file --benchmark not found. It happens because
gem 'test-unit' passes remaining options to the tests, whereas mintest
doesn't do it.

@carlosantoniodasilva
Ruby on Rails member

Nice! I'll give it a try when I find some time here, thanks!

(linking to #4938)

@route

When I want to test my code on performance(for example ActiveRecord or pure Arel/SQL queries), often I have to create big amount of data and for now it is a problem to run rake test:{benchmark,profile} because they purge database before launching tests. WDYT @carlosantoniodasilva can we make it optional or do you have another idea about it?

@route route #4938 Fix launching performance tests
When we run `rake test:benchmark` for performance tests it raises
ArgumentError that file --benchmark not found. It happens because
gem 'test-unit' passes remaining options to the tests, whereas mintest
doesn't do it.
91d4a58
@matthewrobertson

I tested this patch out with ruby-1.9.3-p194 and it fixed similar issues I was having with not being able to run rails benchmarker 'Some.code'

@carlosantoniodasilva
Ruby on Rails member

@matthewrobertson thanks for reporting, this is in my todo list to check asap :).

@senny senny referenced this pull request in rails/rails-perftest
Merged

port PR rails/rails#7416 #2

@senny senny added a commit to rails/rails-perftest that referenced this pull request
@senny senny port PR rails/rails#7416 78311d8
@senny
Ruby on Rails member

As of rails 4 {#8876) performance tests were extracted into a separate gem: https://github.com/rails/rails-perftest

I ported the PR over to that gem and fixed two bugs: rails/rails-perftest#2

I'm closing this one for now. I did not merge the PR into rails-perftest. If you have comments let me know on here: rails/rails-perftest#2

thanks for your work!

@senny senny closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 8, 2012
  1. @route

    #4938 Fix launching performance tests

    route committed
    When we run `rake test:benchmark` for performance tests it raises
    ArgumentError that file --benchmark not found. It happens because
    gem 'test-unit' passes remaining options to the tests, whereas mintest
    doesn't do it.
View
2 activesupport/lib/active_support/testing/performance.rb
@@ -17,7 +17,7 @@ module Performance
# each implementation should define metrics and freeze the defaults
DEFAULTS =
- if ARGV.include?('--benchmark') # HAX for rake test
+ if ENV["BENCHMARK_TESTS"]
{ :runs => 4,
:output => 'tmp/performance',
:benchmark => true }
View
2 activesupport/lib/active_support/testing/performance/jruby.rb
@@ -6,7 +6,7 @@ module ActiveSupport
module Testing
module Performance
DEFAULTS.merge!(
- if ARGV.include?('--benchmark')
+ if ENV["BENCHMARK_TESTS"]
{:metrics => [:wall_time, :user_time, :memory, :gc_runs, :gc_time]}
else
{ :metrics => [:wall_time],
View
2 activesupport/lib/active_support/testing/performance/rubinius.rb
@@ -4,7 +4,7 @@ module ActiveSupport
module Testing
module Performance
DEFAULTS.merge!(
- if ARGV.include?('--benchmark')
+ if ENV["BENCHMARK_TESTS"]
{:metrics => [:wall_time, :memory, :objects, :gc_runs, :gc_time]}
else
{ :metrics => [:wall_time],
View
2 activesupport/lib/active_support/testing/performance/ruby.rb
@@ -9,7 +9,7 @@ module ActiveSupport
module Testing
module Performance
DEFAULTS.merge!(
- if ARGV.include?('--benchmark')
+ if ENV["BENCHMARK_TESTS"]
{ :metrics => [:wall_time, :memory, :objects, :gc_runs, :gc_time] }
else
{ :min_percent => 0.01,
View
2 railties/lib/rails/commands/benchmarker.rb
@@ -2,9 +2,7 @@
require 'rails/test_help'
require 'rails/performance_test_help'
-ARGV.push('--benchmark') # HAX
require 'active_support/testing/performance'
-ARGV.pop
def options
options = {}
View
2 railties/lib/rails/test_unit/testing.rake
@@ -126,7 +126,7 @@ namespace :test do
Rails::SubTestTask.new(:benchmark => 'test:prepare') do |t|
t.libs << 'test'
t.pattern = 'test/performance/**/*_test.rb'
- t.options = '-- --benchmark'
+ ENV["BENCHMARK_TESTS"] = '1'
end
Rails::SubTestTask.new(:profile => 'test:prepare') do |t|
Something went wrong with that request. Please try again.