Sha256: 056d39da57de36b7e11e7b354d443c256713e4ecdc8c564d1888b7971d5ab38c

Contents?: true

Size: 1.26 KB

Versions: 37

Compression:

Stored size: 1.26 KB

Contents

module Skylight
  module VM
    if defined?(JRUBY_VERSION)

      # This doesn't quite work as we would like it. I believe that the GC
      # statistics includes time that is not stop-the-world, this does not
      # necessarily take time away from the application.
      #
      # require 'java'
      # class GC
      #   def initialize
      #     @factory = Java::JavaLangManagement::ManagementFactory
      #   end
      #
      #   def enable
      #   end
      #
      #   def total_time
      #     res = 0.0
      #
      #     @factory.garbage_collector_mx_beans.each do |mx|
      #       res += (mx.collection_time.to_f / 1_000.0)
      #     end
      #
      #     res
      #   end
      # end

    elsif defined?(::GC::Profiler)

      class GC
        def initialize
          @total = 0
        end

        def enable
          ::GC::Profiler.enable
        end

        def total_time
          # Reported in seconds
          run = (::GC::Profiler.total_time * 1_000_000).to_i

          if run > 0
            ::GC::Profiler.clear
          end

          @total += run
        end
      end

    end

    # Fallback
    unless defined?(VM::GC)

      class GC
        def enable
        end

        def total_time
          0
        end
      end

    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
skylight-0.3.10 lib/skylight/vm/gc.rb
skylight-0.3.8 lib/skylight/vm/gc.rb
skylight-0.3.7 lib/skylight/vm/gc.rb
skylight-0.3.6 lib/skylight/vm/gc.rb
skylight-0.3.3 lib/skylight/vm/gc.rb
skylight-0.3.2 lib/skylight/vm/gc.rb
skylight-0.3.1 lib/skylight/vm/gc.rb
skylight-0.3.0 lib/skylight/vm/gc.rb
skylight-0.2.7 lib/skylight/vm/gc.rb
skylight-0.2.6 lib/skylight/vm/gc.rb
skylight-0.3.0.rc.6 lib/skylight/vm/gc.rb
skylight-0.2.5 lib/skylight/vm/gc.rb
skylight-0.2.4 lib/skylight/vm/gc.rb
skylight-0.3.0.rc.5 lib/skylight/vm/gc.rb
skylight-0.3.0.rc.4 lib/skylight/vm/gc.rb
skylight-0.3.0.rc.3 lib/skylight/vm/gc.rb
skylight-0.2.3 lib/skylight/vm/gc.rb
skylight-0.2.2 lib/skylight/vm/gc.rb
skylight-0.2.1 lib/skylight/vm/gc.rb
skylight-0.2.0 lib/skylight/vm/gc.rb