Sha256: 4dbf7e6e1d8634a721f248f6948ec75998a9781e559d73081824d59e188423f8

Contents?: true

Size: 1012 Bytes

Versions: 21

Compression:

Stored size: 1012 Bytes

Contents

# -*- encoding: binary -*-
require 'test/unit'
require 'raindrops'
require 'socket'
require 'benchmark'
$stderr.sync = $stdout.sync = true

class TestLinuxAllTcpListenStatsLeak < Test::Unit::TestCase

  TEST_ADDR = ENV['UNICORN_TEST_ADDR'] || '127.0.0.1'


  def rss_kb
    File.readlines("/proc/#$$/status").grep(/VmRSS:/)[0].split(/\s+/)[1].to_i
  end
  def test_leak
    s = TCPServer.new(TEST_ADDR, 0)
    start_kb = rss_kb
    p [ :start_kb, start_kb ]
    assert_nothing_raised do
      p(Benchmark.measure {
        1000.times { Raindrops::Linux.all_tcp_listener_stats }
      })
    end
    cur_kb = rss_kb
    p [ :cur_kb, cur_kb ]
    now = Time.now.to_i
    fin = now + 60
    assert_nothing_raised do
      1000000000.times { |i|
        if (i % 1024) == 0
          now = Time.now.to_i
          break if now > fin
        end
        Raindrops::Linux.all_tcp_listener_stats
      }
    end
    cur_kb = rss_kb
    p [ :cur_kb, cur_kb ]
    ensure
      s.close
  end
end if ENV["STRESS"].to_i != 0

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
raindrops-0.19.0 test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.18.0 test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.17.0 test/test_linux_all_tcp_listen_stats_leak.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/raindrops-0.16.0/test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.16.0 test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.15.0 test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.14.0.1.g8177 test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.14.0 test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.13.0 test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.12.0.5.g821b test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.12.0 test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.11.0 test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.10.0 test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.9.0 test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.8.1 test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.8.0.5.g71f8 test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.8.0 test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.7.0 test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.6.1 test/test_linux_all_tcp_listen_stats_leak.rb
raindrops-0.6.0 test/test_linux_all_tcp_listen_stats_leak.rb