aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/lib/active_support/testing/performance.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/testing/performance.rb b/activesupport/lib/active_support/testing/performance.rb
index b7a2f368ce..6b7954c5b9 100644
--- a/activesupport/lib/active_support/testing/performance.rb
+++ b/activesupport/lib/active_support/testing/performance.rb
@@ -399,7 +399,18 @@ begin
class GcTime < Base
Mode = RubyProf::GC_TIME if RubyProf.const_defined?(:GC_TIME)
- if RubyProf.respond_to?(:measure_gc_time)
+ # Ruby 1.9 + extented GC profiler patch
+ if defined?(GC::Profiler) and GC::Profiler.respond_to?(:data)
+ def measure
+ GC.enable
+ GC.start
+ sec = GC::Profiler.data.inject(0) { |total, run| total += run[:GC_TIME] }
+ GC.disable
+ sec
+ end
+
+ # Ruby 1.8 + ruby-prof wrapper
+ elsif RubyProf.respond_to?(:measure_gc_time)
def measure
RubyProf.measure_gc_time
end