diff options
author | Gonçalo Silva <goncalossilva@gmail.com> | 2011-03-28 04:19:39 +0100 |
---|---|---|
committer | Gonçalo Silva <goncalossilva@gmail.com> | 2011-03-28 04:19:39 +0100 |
commit | 726b7ede54031eecfcee34eec80040553e9ad19f (patch) | |
tree | 1e4da2700e3fa2b5f459d7ec3e0222a9ba75cb36 | |
parent | 09bd0eeefc5cb3c2cb26e17b486dd0965afbf4d5 (diff) | |
download | rails-726b7ede54031eecfcee34eec80040553e9ad19f.tar.gz rails-726b7ede54031eecfcee34eec80040553e9ad19f.tar.bz2 rails-726b7ede54031eecfcee34eec80040553e9ad19f.zip |
improved detection and feedback of supported/unsupported metrics
6 files changed, 7 insertions, 54 deletions
diff --git a/activesupport/lib/active_support/testing/performance.rb b/activesupport/lib/active_support/testing/performance.rb index 495fcea381..f6945e8466 100644 --- a/activesupport/lib/active_support/testing/performance.rb +++ b/activesupport/lib/active_support/testing/performance.rb @@ -235,44 +235,13 @@ module ActiveSupport end end - class ProcessTime < Time - # overridden by each implementation - def measure; end - end - - class WallTime < Time - # overridden by each implementation - def measure; end - end - - class CpuTime < Time - # overridden by each implementation - def measure; end - end - - class Memory < Base - # overridden by each implementation - def measure; end - + class DigitalInformationUnit < Base def format(measurement) number_to_human_size(measurement, :precision => 2) end end - class Objects < Amount - # overridden by each implementation - def measure; end - end - - class GcRuns < Amount - # overridden by each implementation - def measure; end - end - - class GcTime < Time - # overridden by each implementation - def measure; end - end + # each implementation provides its own metrics like ProcessTime, Memory or GcRuns end end end diff --git a/activesupport/lib/active_support/testing/performance/jruby.rb b/activesupport/lib/active_support/testing/performance/jruby.rb index e489c1f0dd..b76c11f12b 100644 --- a/activesupport/lib/active_support/testing/performance/jruby.rb +++ b/activesupport/lib/active_support/testing/performance/jruby.rb @@ -73,8 +73,6 @@ module ActiveSupport yield end end - - class Time < Base; end class WallTime < Time def measure @@ -94,7 +92,7 @@ module ActiveSupport end end - class Memory < Base + class Memory < DigitalInformationUnit def measure ManagementFactory.memory_mx_bean.non_heap_memory_usage.used + ManagementFactory.memory_mx_bean.heap_memory_usage.used end diff --git a/activesupport/lib/active_support/testing/performance/rubinius.rb b/activesupport/lib/active_support/testing/performance/rubinius.rb index 55b142e20c..a0511f42ed 100644 --- a/activesupport/lib/active_support/testing/performance/rubinius.rb +++ b/activesupport/lib/active_support/testing/performance/rubinius.rb @@ -72,13 +72,6 @@ module ActiveSupport yield end end - - class Time < Base; end - - class ProcessTime < Time - # unsupported - def measure; 0; end - end class WallTime < Time def measure @@ -86,12 +79,7 @@ module ActiveSupport end end - class CpuTime < Time - # unsupported - def measure; 0; end - end - - class Memory < Base + class Memory < DigitalInformationUnit def measure loopback.get("system.memory.counter.bytes").last end diff --git a/activesupport/lib/active_support/testing/performance/ruby.rb b/activesupport/lib/active_support/testing/performance/ruby.rb index 36dc75ca8f..d08eedc653 100644 --- a/activesupport/lib/active_support/testing/performance/ruby.rb +++ b/activesupport/lib/active_support/testing/performance/ruby.rb @@ -102,8 +102,6 @@ module ActiveSupport end end - class Time < Base; end - class ProcessTime < Time Mode = RubyProf::PROCESS_TIME if RubyProf.const_defined?(:PROCESS_TIME) @@ -134,7 +132,7 @@ module ActiveSupport end end - class Memory < Base + class Memory < DigitalInformationUnit Mode = RubyProf::MEMORY if RubyProf.const_defined?(:MEMORY) # overridden by each implementation diff --git a/activesupport/lib/active_support/testing/performance/ruby/mri.rb b/activesupport/lib/active_support/testing/performance/ruby/mri.rb index 512eff30e2..22c31927f0 100644 --- a/activesupport/lib/active_support/testing/performance/ruby/mri.rb +++ b/activesupport/lib/active_support/testing/performance/ruby/mri.rb @@ -16,7 +16,7 @@ module ActiveSupport end end - class Memory < Base + class Memory < DigitalInformationUnit # Ruby 1.8 + ruby-prof wrapper if RubyProf.respond_to?(:measure_memory) def measure diff --git a/activesupport/lib/active_support/testing/performance/ruby/yarv.rb b/activesupport/lib/active_support/testing/performance/ruby/yarv.rb index 38b6e67767..dcbea17a22 100644 --- a/activesupport/lib/active_support/testing/performance/ruby/yarv.rb +++ b/activesupport/lib/active_support/testing/performance/ruby/yarv.rb @@ -23,7 +23,7 @@ module ActiveSupport end end - class Memory < Base + class Memory < DigitalInformationUnit # Ruby 1.9 + GCdata patch if GC.respond_to?(:malloc_allocated_size) def measure |