Sha256: 929a246256049d163cdf9aa9e2c36559c23ed63351236c8353ac344bda0b752f

Contents?: true

Size: 1.76 KB

Versions: 20

Compression:

Stored size: 1.76 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

module Performance
  module Instrumentation
    class MRIGCStats < Instrumentor
      platforms :mri_193, :mri_20, :mri_21, :mri_22
      on_by_default

      def before(*)
        @stats_before = GC.stat
      end

      def after(*)
        @stats_after = GC.stat
      end

      def results
        heap_live_before = @stats_before[:heap_live_slots] || @stats_before[:heap_live_num] || @stats_before[:heap_live_slot]
        heap_live_after  = @stats_after[:heap_live_slots]  || @stats_after[:heap_live_num]  || @stats_after[:heap_live_slot]

        res = {
          :gc_runs      => @stats_after[:count] - @stats_before[:count],
          :live_objects => heap_live_after      - heap_live_before
        }
        if RUBY_VERSION >= "2.0.0"
          allocs_before = @stats_before[:total_allocated_objects] || @stats_before[:total_allocated_object]
          allocs_after  = @stats_after[:total_allocated_objects]  || @stats_after[:total_allocated_object]
          res[:allocations] = allocs_after - allocs_before
        end
        res
      end
    end

    class REEGCStats < Instrumentor
      platforms :ree
      on_by_default

      def before(*)
        @allocations_before = ObjectSpace.allocated_objects
        @live_objects_before = ObjectSpace.live_objects
      end

      def after(*)
        @allocations_after = ObjectSpace.allocated_objects
        @live_objects_after = ObjectSpace.live_objects
      end

      def results
        {
          :allocations => @allocations_after - @allocations_before,
          :live_objects => @live_objects_after - @live_objects_before,
        }
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
newrelic_rpm-3.16.2.321 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.16.1.320 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.16.0.318 test/performance/lib/performance/instrumentation/gc_stats.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-3.15.2.317/test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.15.2.317 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.15.1.316 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.15.0.314 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.14.3.313 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.14.2.312 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.14.1.311 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.14.0.305 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.13.2.302 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.13.1.300 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.13.0.299 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.12.1.298 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.12.0.288 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.11.2.286 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.11.1.284 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.11.0.283 test/performance/lib/performance/instrumentation/gc_stats.rb
newrelic_rpm-3.10.0.279 test/performance/lib/performance/instrumentation/gc_stats.rb