From 726b7ede54031eecfcee34eec80040553e9ad19f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Silva?= Date: Mon, 28 Mar 2011 04:19:39 +0100 Subject: improved detection and feedback of supported/unsupported metrics --- .../lib/active_support/testing/performance.rb | 35 ++-------------------- .../active_support/testing/performance/jruby.rb | 4 +-- .../active_support/testing/performance/rubinius.rb | 14 +-------- .../lib/active_support/testing/performance/ruby.rb | 4 +-- .../active_support/testing/performance/ruby/mri.rb | 2 +- .../testing/performance/ruby/yarv.rb | 2 +- 6 files changed, 7 insertions(+), 54 deletions(-) (limited to 'activesupport/lib/active_support/testing') 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 -- cgit v1.2.3