diff options
author | Gonçalo Silva <goncalossilva@gmail.com> | 2011-03-25 02:39:43 +0000 |
---|---|---|
committer | Gonçalo Silva <goncalossilva@gmail.com> | 2011-03-25 02:39:43 +0000 |
commit | 11516089212a67e154ec426787feb6f24ed7e129 (patch) | |
tree | b39f42a82e65de9f35b4e1fb550d011adb271cc5 | |
parent | e57d264f3795537cc3a5be61d766f956f882a5bd (diff) | |
download | rails-11516089212a67e154ec426787feb6f24ed7e129.tar.gz rails-11516089212a67e154ec426787feb6f24ed7e129.tar.bz2 rails-11516089212a67e154ec426787feb6f24ed7e129.zip |
using number_helper to pretty print some results
-rw-r--r-- | activesupport/lib/active_support/testing/performance.rb | 29 | ||||
-rw-r--r-- | activesupport/lib/active_support/testing/performance/mri.rb | 6 |
2 files changed, 16 insertions, 19 deletions
diff --git a/activesupport/lib/active_support/testing/performance.rb b/activesupport/lib/active_support/testing/performance.rb index db7611c4fa..0d7d405127 100644 --- a/activesupport/lib/active_support/testing/performance.rb +++ b/activesupport/lib/active_support/testing/performance.rb @@ -2,6 +2,7 @@ require 'fileutils' require 'rails/version' require 'active_support/core_ext/class/delegating_attributes' require 'active_support/core_ext/string/inflections' +require 'action_view/helpers/number_helper' module ActiveSupport module Testing @@ -179,6 +180,8 @@ module ActiveSupport end class Base + include ActionView::Helpers::NumberHelper + attr_reader :total def initialize @@ -219,6 +222,12 @@ module ActiveSupport end end + class Amount < Base + def format(measurement) + number_with_delimiter(measurement) + end + end + class ProcessTime < Time # overridden by each implementation def measure; end @@ -239,35 +248,23 @@ module ActiveSupport def measure; end def format(measurement) - '%.2f KB' % measurement + number_to_human_size(measurement, :precision => 2) end end - class Objects < Base + class Objects < Amount # overridden by each implementation def measure; end - - def format(measurement) - measurement.to_i.to_s - end end - class GcRuns < Base + class GcRuns < Amount # overridden by each implementation def measure; end - - def format(measurement) - measurement.to_i.to_s - end end - class GcTime < Base + class GcTime < Time # overridden by each implementation def measure; end - - def format(measurement) - '%.2f ms' % measurement - end end end end diff --git a/activesupport/lib/active_support/testing/performance/mri.rb b/activesupport/lib/active_support/testing/performance/mri.rb index 914e546090..859588c735 100644 --- a/activesupport/lib/active_support/testing/performance/mri.rb +++ b/activesupport/lib/active_support/testing/performance/mri.rb @@ -158,7 +158,7 @@ module ActiveSupport end end - class Objects < Base + class Objects < Amount Mode = RubyProf::ALLOCATIONS if RubyProf.const_defined?(:ALLOCATIONS) # Ruby 1.9 + GCdata patch @@ -175,7 +175,7 @@ module ActiveSupport end end - class GcRuns < Base + class GcRuns < Amount Mode = RubyProf::GC_RUNS if RubyProf.const_defined?(:GC_RUNS) # Ruby 1.9 @@ -192,7 +192,7 @@ module ActiveSupport end end - class GcTime < Base + class GcTime < Time Mode = RubyProf::GC_TIME if RubyProf.const_defined?(:GC_TIME) # Ruby 1.9 with GC::Profiler |