Permalink
Browse files

use GC profiler extended patch to retrieve GC runs on 1.9

  • Loading branch information...
1 parent 555c3b5 commit 175164397bfa9c5ac1c96e4c4efd4bed8d5e9bcd @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
@@ -374,7 +374,18 @@ def format(measurement)
class GcRuns < Base
Mode = RubyProf::GC_RUNS if RubyProf.const_defined?(:GC_RUNS)
- if RubyProf.respond_to?(:measure_gc_runs)
+ # Ruby 1.9 + extented GC profiler patch
+ if defined?(GC::Profiler) and GC::Profiler.respond_to?(:data)
+ def measure
+ GC.enable
+ GC.start
+ count = GC::Profiler.data.last[:GC_RUNS]
+ GC.disable
+ count
+ end
+
+ # Ruby 1.8 + ruby-prof wrapper
+ elsif RubyProf.respond_to?(:measure_gc_runs)
def measure
RubyProf.measure_gc_runs
end

0 comments on commit 1751643

Please sign in to comment.