Sha256: 234441ed1666b95592a3c3e69bb7f2042e5e53b1792419c64662a47e6f6401cf

Contents?: true

Size: 497 Bytes

Versions: 1

Compression:

Stored size: 497 Bytes

Contents

require 'benchmark'

def busywork
  GC.disable
  100_000.times do |i|
    Object.new

    if i % 10_000 == 0
      GC.enable
      GC.start
      GC.disable
    end
  end
  GC.enable
end

def busywork_with_profiling
  GC::Profiler.enable
  busywork
  GC::Profiler.disable
  GC::Profiler.clear
end

N = 1_000

Benchmark.bmbm do |bm|
  bm.report 'GC Profile' do
    N.times do
      busywork_with_profiling
    end
  end

  bm.report 'No Profile' do
    N.times do
      busywork
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack_gc_profiler-0.1.0 benchmark.rb