From 5e5d1babb0ab381ad471228904262312aa1fc297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Silva?= Date: Sat, 12 Jun 2010 11:53:13 +0100 Subject: also use GC profiler extended patch to retrieve GC time on 1.9 --- activesupport/lib/active_support/testing/performance.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'activesupport') 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 -- cgit v1.2.3