diff options
author | Gonçalo Silva <goncalossilva@gmail.com> | 2011-03-28 00:33:36 +0100 |
---|---|---|
committer | Gonçalo Silva <goncalossilva@gmail.com> | 2011-03-28 00:33:36 +0100 |
commit | ef988e12d8dc4fb82f46f953cac8ad64bbc08c8a (patch) | |
tree | 552cac1ca65816167d617740ebbb6703c95c3dbe | |
parent | 15bff5a86e916ee250f800b7c67d79fed9d5757b (diff) | |
download | rails-ef988e12d8dc4fb82f46f953cac8ad64bbc08c8a.tar.gz rails-ef988e12d8dc4fb82f46f953cac8ad64bbc08c8a.tar.bz2 rails-ef988e12d8dc4fb82f46f953cac8ad64bbc08c8a.zip |
removed duplication in rubinius' benchmark code
-rw-r--r-- | activesupport/lib/active_support/testing/performance/rubinius.rb | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/activesupport/lib/active_support/testing/performance/rubinius.rb b/activesupport/lib/active_support/testing/performance/rubinius.rb index c8813a22df..67d21e2a43 100644 --- a/activesupport/lib/active_support/testing/performance/rubinius.rb +++ b/activesupport/lib/active_support/testing/performance/rubinius.rb @@ -13,8 +13,8 @@ module ActiveSupport def run_gc GC.run(true) end - - class Performer; end + + class Performer; end class Profiler < Performer def run @@ -33,29 +33,25 @@ module ActiveSupport def record if(profile_options[:formats].include?(:flat)) - File.open(output_filename('FlatPrinter'), 'wb') do |file| + create_path_and_open_file(:flat) do |file| @profiler.show(file) end end if(profile_options[:formats].include?(:graph)) - @profiler.set_options({:graph => true}) - File.open(output_filename('GraphPrinter'), 'wb') do |file| + create_path_and_open_file(:graph) do |file| @profiler.show(file) end end end protected - def output_filename(printer) - suffix = - case printer - when 'FlatPrinter'; 'flat.txt' - when 'GraphPrinter'; 'graph.txt' - else printer.sub(/Printer$/, '').underscore - end - - "#{super()}_#{suffix}" + def create_path_and_open_file(printer_name) + fname = "#{output_filename}_#{printer_name}.txt" + FileUtils.mkdir_p(fname) + File.open(fname, 'wb') do |file| + yield(file) + end end end |