diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2012-01-30 11:37:24 -0800 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2012-01-30 11:37:24 -0800 |
commit | 211174a3be8554d54f2df140e601b8d39cc89824 (patch) | |
tree | 060feff20433f59d1a6a940e675dd6f67e24d9b9 /activesupport/lib/active_support/testing/performance/ruby.rb | |
parent | 7cdb12286639b38db2eb1e9fd0c8b2e6bc3b39dc (diff) | |
parent | 94cd8d7450cef8516cc759114c4f5af966bd76cb (diff) | |
download | rails-211174a3be8554d54f2df140e601b8d39cc89824.tar.gz rails-211174a3be8554d54f2df140e601b8d39cc89824.tar.bz2 rails-211174a3be8554d54f2df140e601b8d39cc89824.zip |
Merge pull request #4767 from lest/patch-2
merge MRI performance methods into one file
Diffstat (limited to 'activesupport/lib/active_support/testing/performance/ruby.rb')
-rw-r--r-- | activesupport/lib/active_support/testing/performance/ruby.rb | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/testing/performance/ruby.rb b/activesupport/lib/active_support/testing/performance/ruby.rb index 26731c6bd7..b7a34ea279 100644 --- a/activesupport/lib/active_support/testing/performance/ruby.rb +++ b/activesupport/lib/active_support/testing/performance/ruby.rb @@ -86,9 +86,12 @@ module ActiveSupport end protected - # overridden by each implementation def with_gc_stats + GC::Profiler.enable + GC.start yield + ensure + GC::Profiler.disable end end @@ -124,27 +127,42 @@ module ActiveSupport class Memory < DigitalInformationUnit Mode = RubyProf::MEMORY if RubyProf.const_defined?(:MEMORY) + + # Ruby 1.9 + GCdata patch + if GC.respond_to?(:malloc_allocated_size) + def measure + GC.malloc_allocated_size + end + end end class Objects < Amount Mode = RubyProf::ALLOCATIONS if RubyProf.const_defined?(:ALLOCATIONS) + + # Ruby 1.9 + GCdata patch + if GC.respond_to?(:malloc_allocations) + def measure + GC.malloc_allocations + end + end end class GcRuns < Amount Mode = RubyProf::GC_RUNS if RubyProf.const_defined?(:GC_RUNS) + + def measure + GC.count + end end class GcTime < Time Mode = RubyProf::GC_TIME if RubyProf.const_defined?(:GC_TIME) + + def measure + GC::Profiler.total_time + end end end end end end - -if RUBY_VERSION.between?('1.9.2', '2.0') - require 'active_support/testing/performance/ruby/yarv' -else - $stderr.puts 'Update your ruby interpreter to be able to run benchmarks.' - exit -end |