Skip to content

Instantly share code, notes, and snippets.

@tcannonfodder
Created July 31, 2014 19:07
Show Gist options
  • Save tcannonfodder/e4ea2d7f877bdcc5dcdf to your computer and use it in GitHub Desktop.
Save tcannonfodder/e4ea2d7f877bdcc5dcdf to your computer and use it in GitHub Desktop.
Running Rail 2.3 LTS Performance Tests using Minitest
# include this in your test_helper.rb. It monkeypatches
# The methods used to actually run any performance tests
# subclassed from ActionController::PerformanceTest
# based on: https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/testing/performance.rb#L44
module ActiveSupport
module Testing
module Performance
def run(runner)
@runner = runner
run_warmup
if profile_options && metrics = profile_options[:metrics]
metrics.each do |metric_name|
if klass = Metrics[metric_name.to_sym]
run_profile(klass.new)
end
end
end
return
end
def run_test(metric, mode)
result = '.'
begin
run_callbacks :setup
setup
metric.send(mode) { __send__ method_name }
rescue Exception => e
result = @runner.puke(self.class, method_name, e)
ensure
begin
teardown
run_callbacks :teardown, :enumerator => :reverse_each
rescue Exception => e
result = @runner.puke(self.class, method_name, e)
end
end
result
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment