Permalink
Browse files

also use GC profiler extended patch to retrieve GC time on 1.9

  • Loading branch information...
1 parent f02d3f9 commit 5e5d1babb0ab381ad471228904262312aa1fc297 @goncalossilva goncalossilva committed with wycats Jun 12, 2010
Showing with 12 additions and 1 deletion.
  1. +12 −1 activesupport/lib/active_support/testing/performance.rb
@@ -399,7 +399,18 @@ def format(measurement)
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

0 comments on commit 5e5d1ba

Please sign in to comment.