Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

improved detection and feedback of supported/unsupported metrics

  • Loading branch information...
commit 726b7ede54031eecfcee34eec80040553e9ad19f 1 parent 09bd0ee
@goncalossilva goncalossilva authored
View
35 activesupport/lib/active_support/testing/performance.rb
@@ -235,44 +235,13 @@ def format(measurement)
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
View
4 activesupport/lib/active_support/testing/performance/jruby.rb
@@ -73,8 +73,6 @@ def with_gc_stats
yield
end
end
-
- class Time < Base; end
class WallTime < Time
def measure
@@ -94,7 +92,7 @@ def measure
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
View
14 activesupport/lib/active_support/testing/performance/rubinius.rb
@@ -72,13 +72,6 @@ def with_gc_stats
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 @@ def measure
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
View
4 activesupport/lib/active_support/testing/performance/ruby.rb
@@ -102,8 +102,6 @@ def with_gc_stats
end
end
- class Time < Base; end
-
class ProcessTime < Time
Mode = RubyProf::PROCESS_TIME if RubyProf.const_defined?(:PROCESS_TIME)
@@ -134,7 +132,7 @@ def measure
end
end
- class Memory < Base
+ class Memory < DigitalInformationUnit
Mode = RubyProf::MEMORY if RubyProf.const_defined?(:MEMORY)
# overridden by each implementation
View
2  activesupport/lib/active_support/testing/performance/ruby/mri.rb
@@ -16,7 +16,7 @@ def with_gc_stats
end
end
- class Memory < Base
+ class Memory < DigitalInformationUnit
# Ruby 1.8 + ruby-prof wrapper
if RubyProf.respond_to?(:measure_memory)
def measure
View
2  activesupport/lib/active_support/testing/performance/ruby/yarv.rb
@@ -23,7 +23,7 @@ def with_gc_stats
end
end
- class Memory < Base
+ class Memory < DigitalInformationUnit
# Ruby 1.9 + GCdata patch
if GC.respond_to?(:malloc_allocated_size)
def measure
Please sign in to comment.
Something went wrong with that request. Please try again.