aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorGonçalo Silva <goncalossilva@gmail.com>2010-06-12 11:53:13 +0100
committerwycats <wycats@gmail.com>2010-06-17 19:18:53 -0700
commit5e5d1babb0ab381ad471228904262312aa1fc297 (patch)
tree502f5056de1bbbbb76e3a4e01faa24898d0f88c7 /activesupport/lib/active_support
parentf02d3f9eeeacf49973d6826a345749075af96a69 (diff)
downloadrails-5e5d1babb0ab381ad471228904262312aa1fc297.tar.gz
rails-5e5d1babb0ab381ad471228904262312aa1fc297.tar.bz2
rails-5e5d1babb0ab381ad471228904262312aa1fc297.zip
also use GC profiler extended patch to retrieve GC time on 1.9
Diffstat (limited to 'activesupport/lib/active_support')
-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