aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonçalo Silva <goncalossilva@gmail.com>2010-06-12 11:51:40 +0100
committerwycats <wycats@gmail.com>2010-06-17 19:18:52 -0700
commit175164397bfa9c5ac1c96e4c4efd4bed8d5e9bcd (patch)
treee7768bee970f74ebf6ead891acc9e9060905dd3d
parent555c3b5abe9f8246ea0d5319f5b44db73324fabf (diff)
downloadrails-175164397bfa9c5ac1c96e4c4efd4bed8d5e9bcd.tar.gz
rails-175164397bfa9c5ac1c96e4c4efd4bed8d5e9bcd.tar.bz2
rails-175164397bfa9c5ac1c96e4c4efd4bed8d5e9bcd.zip
use GC profiler extended patch to retrieve GC runs on 1.9
-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 866326baff..c882b088ce 100644
--- a/activesupport/lib/active_support/testing/performance.rb
+++ b/activesupport/lib/active_support/testing/performance.rb
@@ -374,7 +374,18 @@ begin
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