bleak_house 3.1 → 3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+
2
+ # Override Dispatcher#prepare and Dispatcher#reset_after_dispatch so that each request makes before-and-after usage snapshots.
3
+ class Dispatcher
4
+ class << self
5
+
6
+ def prepare_application_with_bleak_house
7
+ prepare_application_without_bleak_house
8
+ BleakHouse::Rails::MEMLOGGER.snapshot(BleakHouse::Rails::LOGFILE, 'core rails', BleakHouse::Rails::WITH_SPECIALS)
9
+ end
10
+ alias_method_chain :prepare_application, :bleak_house
11
+
12
+ def reset_after_dispatch_with_bleak_house
13
+ BleakHouse::Rails::MEMLOGGER.snapshot(BleakHouse::Rails::LOGFILE, BleakHouse::Rails.last_request_name || 'unknown', BleakHouse::Rails::WITH_SPECIALS)
14
+ reset_after_dispatch_without_bleak_house
15
+ end
16
+ alias_method_chain :reset_after_dispatch, :bleak_house
17
+
18
+ end
19
+ end
@@ -0,0 +1,53 @@
1
+
2
+ if RUBY_PLATFORM =~ /win32|windows/
3
+ puts "ERROR: windows not supported."
4
+ exit
5
+ end
6
+
7
+ require 'fileutils'
8
+ puts "Building patched Ruby binary"
9
+
10
+ tmp = "/tmp/"
11
+ Dir.chdir(tmp) do
12
+
13
+ build_dir = "bleak_house"
14
+ binary_dir = File.dirname(`which ruby`)
15
+ FileUtils.rm_rf(build_dir) rescue nil
16
+ Dir.mkdir(build_dir)
17
+
18
+ begin
19
+ Dir.chdir(build_dir) do
20
+ puts " Downloading Ruby source"
21
+ bz2 = "ruby-1.8.6.tar.bz2"
22
+ system("wget 'http://rubyforge.org/frs/download.php/18434/ruby-1.8.6.tar.bz2' &> wget.log")
23
+ puts " Extracting"
24
+ system("tar xjf #{bz2} &> tar.log")
25
+ File.delete bz2
26
+
27
+ Dir.chdir("ruby-1.8.6") do
28
+ puts " Patching"
29
+ system("patch -p0 < \'#{File.dirname(__FILE__)}/../../../patches/gc.c.patch\' &> ../gc.c.patch.log")
30
+ system("patch -p0 < \'#{File.dirname(__FILE__)}/../../../patches/parse.y.patch\' &> ../parse.y.patch.log")
31
+ puts " Configuring"
32
+ system("./configure --prefix=#{binary_dir[0..-5]} &> ../configure.log") # --with-static-linked-ext
33
+ puts " Making"
34
+ system("make &> ../make.log")
35
+
36
+ binary = "#{binary_dir}/ruby-bleak-house"
37
+ puts " Installing as #{binary}"
38
+
39
+ if File.exist? "ruby"
40
+ # Avoid a "Text file busy" error
41
+ exec("rm #{binary}; cp ./ruby #{binary}; chmod -755 #{binary}; echoe \" Done\"")
42
+ else
43
+ raise "Binary did not build"
44
+ end
45
+ end
46
+
47
+ end
48
+ rescue Object => e
49
+ puts "ERROR: please see the last modified log file in #{tmp}#{build_dir}, perhaps\nit will contain a clue.\n#{e.to_s}"
50
+ end
51
+
52
+ end
53
+
@@ -1,4 +1,6 @@
1
1
 
2
+ require 'set'
3
+
2
4
  class Array
3
5
  alias :time :first
4
6
  alias :data :last
@@ -13,6 +15,24 @@ class Array
13
15
 
14
16
  end
15
17
 
18
+ class Hash
19
+
20
+ # Similar to the ActiveSupport methods in Rails
21
+ def slice(keys)
22
+ keys = Set.new(keys)
23
+ reject do |key,|
24
+ !keys.include?(key)
25
+ end
26
+ end
27
+
28
+ def unslice(keys)
29
+ keys = Set.new(keys)
30
+ reject do |key,|
31
+ keys.include?(key)
32
+ end
33
+ end
34
+ end
35
+
16
36
  class Dir
17
37
  def self.descend path, &block
18
38
  path = path.split("/") unless path.is_a? Array
@@ -44,4 +64,7 @@ class Symbol
44
64
  def =~ regex
45
65
  self.to_s =~ regex
46
66
  end
67
+ def [](*args)
68
+ self.to_s[*args]
69
+ end
47
70
  end
@@ -0,0 +1,168 @@
1
+ # = LightCsv
2
+ # CSV parser
3
+ #
4
+ # $Id: lightcsv.rb 76 2007-04-15 14:34:23Z tommy $
5
+ # Copyright:: 2007 (C) TOMITA Masahiro <tommy@tmtm.org>
6
+ # License:: Ruby's
7
+ # Homepage:: http://tmtm.org/ja/ruby/lightcsv
8
+
9
+ require "strscan"
10
+
11
+ # == CSV のパース
12
+ # 各レコードはカラムを要素とする配列である。
13
+ # レコードの区切りは LF,CR,CRLF のいずれか。
14
+ #
15
+ # 以下が csv.rb と異なる。
16
+ # * 空行は [nil] ではなく [] になる。
17
+ # * 「"」で括られていない空カラムは nil ではなく "" になる。
18
+ #
19
+ # == 例
20
+ # * CSVファイルのレコード毎にブロックを繰り返す。
21
+ # LightCsv.foreach(filename){|row| ...}
22
+ # 次と同じ。
23
+ # LightCsv.open(filename){|csv| csv.each{|row| ...}}
24
+ #
25
+ # * CSVファイルの全レコードを返す。
26
+ # LightCsv.readlines(filename) # => [[col1,col2,...],...]
27
+ # 次と同じ。
28
+ # LightCsv.open(filename){|csv| csv.map}
29
+ #
30
+ # * CSV文字列のレコード毎にブロックを繰り返す。
31
+ # LightCsv.parse("a1,a2,..."){|row| ...}
32
+ # 次と同じ。
33
+ # LightCsv.new("a1,a2,...").each{|row| ...}
34
+ #
35
+ # * CSV文字列の全レコードを返す。
36
+ # LightCsv.parse("a1,a2,...") # => [[a1,a2,...],...]
37
+ # 次と同じ。
38
+ # LightCsv.new("a1,a2,...").map
39
+ #
40
+ class LightCsv
41
+ include Enumerable
42
+
43
+ # == パースできない形式の場合に発生する例外
44
+ # InvalidFormat#message は処理できなかった位置から 10バイト文の文字列を返す。
45
+ class InvalidFormat < RuntimeError; end
46
+
47
+ # ファイルの各レコード毎にブロックを繰り返す。
48
+ # ブロック引数はレコードを表す配列。
49
+ def self.foreach(filename, &block)
50
+ self.open(filename) do |f|
51
+ f.each(&block)
52
+ end
53
+ end
54
+
55
+ # ファイルの全レコードをレコードの配列で返す。
56
+ def self.readlines(filename)
57
+ self.open(filename) do |f|
58
+ return f.map
59
+ end
60
+ end
61
+
62
+ # CSV文字列の全レコードをレコードの配列で返す。
63
+ # ブロックが与えられた場合は、レコード毎にブロックを繰り返す。
64
+ # ブロック引数はレコードを表す配列。
65
+ def self.parse(string, &block)
66
+ unless block
67
+ return self.new(string).map
68
+ end
69
+ self.new(string).each do |row|
70
+ block.call row
71
+ end
72
+ return nil
73
+ end
74
+
75
+ # ファイルをオープンして LightCsv オブジェクトを返す。
76
+ # ブロックを与えた場合は LightCsv オブジェクトを引数としてブロックを実行する。
77
+ def self.open(filename, &block)
78
+ f = File.open(filename)
79
+ csv = self.new(f)
80
+ if block
81
+ begin
82
+ return block.call(csv)
83
+ ensure
84
+ csv.close
85
+ end
86
+ else
87
+ return csv
88
+ end
89
+ end
90
+
91
+ # LightCsv オブジェクトを生成する。
92
+ # _src_ は String か IO。
93
+ def initialize(src)
94
+ if src.kind_of? String
95
+ @file = nil
96
+ @ss = StringScanner.new(src)
97
+ else
98
+ @file = src
99
+ @ss = StringScanner.new("")
100
+ end
101
+ @buf = ""
102
+ @bufsize = 64*1024
103
+ end
104
+ attr_accessor :bufsize
105
+
106
+ # LightCsv オブジェクトに関連したファイルをクローズする。
107
+ def close()
108
+ @file.close if @file
109
+ end
110
+
111
+ # 1レコードを返す。データの最後の場合は nil を返す。
112
+ # 空行の場合は空配列([])を返す。
113
+ # 空カラムは「"」で括られているか否かにかかわらず空文字列("")になる。
114
+ def shift()
115
+ return nil if @ss.eos? and ! read_next_data
116
+ cols = []
117
+ while true
118
+ if @ss.eos? and ! read_next_data
119
+ cols << ""
120
+ break
121
+ end
122
+ if @ss.scan(/\"/n)
123
+ until @ss.scan(/(?:\"\"|[^\"])*\"/n)
124
+ read_next_data or raise InvalidFormat, @ss.rest[0,10]
125
+ end
126
+ cols << @ss.matched.chop.gsub(/\"\"/n, '"')
127
+ else
128
+ col = @ss.scan(/[^\",\r\n]*/n)
129
+ while @ss.eos? and read_next_data
130
+ col << @ss.scan(/[^\",\r\n]*/n)
131
+ end
132
+ cols << col
133
+ end
134
+ unless @ss.scan(/,/n)
135
+ break if @ss.scan(/\r\n/n)
136
+ unless @ss.rest_size < 2 and read_next_data and @ss.scan(/,/n)
137
+ break if @ss.scan(/\r\n|\n|\r|\z/n)
138
+ read_next_data
139
+ raise InvalidFormat, @ss.rest[0,10]
140
+ end
141
+ end
142
+ end
143
+ cols.clear if cols.size == 1 and cols.first.empty?
144
+ cols
145
+ end
146
+
147
+ # 各レコード毎にブロックを繰り返す。
148
+ def each()
149
+ while row = shift
150
+ yield row
151
+ end
152
+ end
153
+
154
+ # 現在位置以降のレコードの配列を返す。
155
+ def readlines()
156
+ return map
157
+ end
158
+
159
+ private
160
+
161
+ def read_next_data()
162
+ if @file and @file.read(@bufsize, @buf)
163
+ @ss.string = @ss.rest + @buf
164
+ else
165
+ nil
166
+ end
167
+ end
168
+ end
@@ -0,0 +1,27 @@
1
+ *** gc.old 2007-09-25 00:27:27.000000000 -0400
2
+ --- gc.c 2007-09-25 00:27:28.000000000 -0400
3
+ ***************
4
+ *** 309,314 ****
5
+ --- 309,330 ----
6
+ static int heaps_length = 0;
7
+ static int heaps_used = 0;
8
+
9
+ + struct heaps_slot *
10
+ + rb_gc_heap_slots()
11
+ + {
12
+ + return heaps;
13
+ + }
14
+ +
15
+ + int
16
+ + rb_gc_heaps_used() {
17
+ + return heaps_used;
18
+ + }
19
+ +
20
+ + int
21
+ + rb_gc_heaps_length() {
22
+ + return heaps_length;
23
+ + }
24
+ +
25
+ #define HEAP_MIN_SLOTS 10000
26
+ static int heap_slots = HEAP_MIN_SLOTS;
27
+
@@ -0,0 +1,16 @@
1
+ *** parse.old 2007-09-25 00:21:43.000000000 -0400
2
+ --- parse.y 2007-09-25 00:23:02.000000000 -0400
3
+ ***************
4
+ *** 6166,6171 ****
5
+ --- 6166,6176 ----
6
+ * :wait2, :$>]
7
+ */
8
+
9
+ + struct st_table *
10
+ + rb_parse_sym_tbl() {
11
+ + return sym_tbl;
12
+ + }
13
+ +
14
+ VALUE
15
+ rb_sym_all_symbols()
16
+ {
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby-bleak-house
2
+
3
+ require 'rubygems'
4
+ require 'bleak_house/c'
5
+ $memlogger = BleakHouse::Logger.new
6
+ File.delete($logfile = "/tmp/log") rescue nil
7
+
8
+ puts 0
9
+ $memlogger.snapshot($logfile, "file", true)
10
+ puts 1
11
+ $memlogger.snapshot($logfile, "file/one", true)
12
+ puts 2
13
+ $memlogger.snapshot($logfile, "file/two", true)
@@ -0,0 +1,34 @@
1
+
2
+ DIR = File.dirname(__FILE__) + "/../../"
3
+
4
+ require 'rubygems'
5
+ require 'test/unit'
6
+ require 'yaml'
7
+ require 'ruby-debug'
8
+ Debugger.start
9
+
10
+ class BleakHouseTest < Test::Unit::TestCase
11
+ require "#{DIR}lib/bleak_house/logger"
12
+
13
+ SNAPSHOT_FILE = "/tmp/bleak_house"
14
+ SNAPS = {:c => SNAPSHOT_FILE + ".c.yaml",
15
+ :ruby => SNAPSHOT_FILE + ".rb.yaml"}
16
+
17
+ def setup
18
+ end
19
+
20
+ def test_c_snapshot
21
+ File.delete SNAPS[:c] rescue nil
22
+ symbol_count = Symbol.all_symbols.size
23
+ ::BleakHouse::Logger.new.snapshot(SNAPS[:c], "c_test", false)
24
+ assert_equal symbol_count, Symbol.all_symbols.size
25
+ assert File.exist?(SNAPS[:c])
26
+ end
27
+
28
+ def test_c_raises
29
+ assert_raises(RuntimeError) do
30
+ ::BleakHouse::Logger.new.snapshot("/", "c_test", false)
31
+ end
32
+ end
33
+
34
+ end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.2
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: bleak_house
5
5
  version: !ruby/object:Gem::Version
6
- version: "3.1"
7
- date: 2007-05-01 00:00:00 -04:00
8
- summary: BleakHouse is a Rails plugin for finding memory leaks. It tracks ObjectSpace for your entire app, and produces charts of references by controller, by action, and by object class.
6
+ version: "3.2"
7
+ date: 2007-09-26 00:00:00 -04:00
8
+ summary: A library for finding memory leaks.
9
9
  require_paths:
10
10
  - lib
11
- email: evan at cloudbur dot st
12
- homepage: http://blog.evanweaver.com
11
+ - ext
12
+ email: ""
13
+ homepage: http://blog.evanweaver.com/files/doc/fauna/bleak_house/
13
14
  rubyforge_project: fauna
14
- description: BleakHouse is a Rails plugin for finding memory leaks. It tracks ObjectSpace for your entire app, and produces charts of references by controller, by action, and by object class.
15
+ description: A library for finding memory leaks.
15
16
  autorequire:
16
17
  default_executable:
17
18
  bindir: bin
@@ -25,55 +26,82 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
26
  platform: ruby
26
27
  signing_key:
27
28
  cert_chain:
28
- post_install_message: |+
29
-
30
- Thanks for installing Bleak House 3.1.
31
-
32
- For each Rails app you want to profile, you will need to add the following
33
- rake task in RAILS_ROOT/lib/tasks/bleak_house_tasks.rake to be able to run
34
- the analyzer:
35
-
36
- namespace :bleak_house do
37
- desc 'Analyze and chart all data'
38
- task :analyze do
39
- require 'bleak_house/analyze'
40
- BleakHouse::Analyze.build_all("#{RAILS_ROOT}/log/bleak_house_#{RAILS_ENV}.dump")
41
- end
42
- end
43
-
44
-
29
+ - |
30
+ -----BEGIN CERTIFICATE-----
31
+ MIIDLjCCAhagAwIBAgIBADANBgkqhkiG9w0BAQUFADA9MQ0wCwYDVQQDDARldmFu
32
+ MRgwFgYKCZImiZPyLGQBGRYIY2xvdWRidXIxEjAQBgoJkiaJk/IsZAEZFgJzdDAe
33
+ Fw0wNzA5MTYxMDMzMDBaFw0wODA5MTUxMDMzMDBaMD0xDTALBgNVBAMMBGV2YW4x
34
+ GDAWBgoJkiaJk/IsZAEZFghjbG91ZGJ1cjESMBAGCgmSJomT8ixkARkWAnN0MIIB
35
+ IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5C0Io89nyApnr+PvbNFge9Vs
36
+ yRWAlGBUEMahpXp28VrrfXZT0rAW7JBo4PlCE3jl4nE4dzE6gAdItSycjTosrw7A
37
+ Ir5+xoyl4Vb35adv56TIQQXvNz+BzlqnkAY5JN0CSBRTQb6mxS3hFyD/h4qgDosj
38
+ R2RFVzHqSxCS8xq4Ny8uzOwOi+Xyu4w67fI5JvnPvMxqrlR1eaIQHmxnf76RzC46
39
+ QO5QhufjAYGGXd960XzbQsQyTDUYJzrvT7AdOfiyZzKQykKt8dEpDn+QPjFTnGnT
40
+ QmgJBX5WJN0lHF2l1sbv3gh4Kn1tZu+kTUqeXY6ShAoDTyvZRiFqQdwh8w2lTQID
41
+ AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU+WqJz3xQ
42
+ XSea1hRvvHWcIMgeeC4wDQYJKoZIhvcNAQEFBQADggEBAGLZ75jfOEW8Nsl26CTt
43
+ JFrWxQTcQT/UljeefVE3xYr7lc9oQjbqO3FOyued3qW7TaNEtZfSHoYeUSMYbpw1
44
+ XAwocIPuSRFDGM4B+hgQGVDx8PMGiJKom4qLXjO40UZsR7QyN/u869Vj45LURm6h
45
+ MBcPeqCASI+WNprj9+uZa2kmHiitrFqqfMBNlm5IFbn9XeYSta9AHVvs5QQqV2m5
46
+ hIPfLqCyxsn/YgOGvo6iwyQTWyTswamaAC3HRWZxIS1sfn/Ssqa7E7oQMkv5FAXr
47
+ x5rKePfXINf8XTJczkl9OBEYdE9aNdJsJpXD0asLgGVwBICS5Bjohp6mizJcDC1+
48
+ yZ0=
49
+ -----END CERTIFICATE-----
50
+
51
+ post_install_message:
45
52
  authors:
46
53
  - Evan Weaver
47
54
  files:
48
- - ./CHANGELOG
49
- - ./LICENSE
50
- - ./Manifest
51
- - ./README
52
- - ./Rakefile
53
- - ./init.rb
54
- - ./install.rb
55
- - ./lib/bleak_house
56
- - ./lib/bleak_house/action_controller.rb
57
- - ./lib/bleak_house/analyze.rb
58
- - ./lib/bleak_house/bleak_house.rb
59
- - ./lib/bleak_house/dispatcher.rb
60
- - ./lib/bleak_house/gruff_hacks.rb
61
- - ./lib/bleak_house/mem_logger.rb
62
- - ./lib/bleak_house/rake_task_redefine_task.rb
63
- - ./lib/bleak_house/support_methods.rb
64
- - ./lib/bleak_house.rb
65
- - ./tasks/bleak_house_tasks.rake
66
- test_files: []
67
-
55
+ - TODO
56
+ - test/unit/test_bleak_house.rb
57
+ - test/misc/direct.rb
58
+ - README
59
+ - Rakefile
60
+ - patches/parse.y.patch
61
+ - patches/gc.c.patch
62
+ - Manifest
63
+ - LICENSE_RUBY
64
+ - LICENSE_BSD
65
+ - LICENSE
66
+ - lib/vendor/lightcsv.rb
67
+ - lib/bleak_house.rb
68
+ - lib/bleak_house/support/rake.rb
69
+ - lib/bleak_house/support/core_extensions.rb
70
+ - lib/bleak_house/support/build.rb
71
+ - lib/bleak_house/rails.rb
72
+ - lib/bleak_house/rails/dispatcher.rb
73
+ - lib/bleak_house/rails/bleak_house.rb
74
+ - lib/bleak_house/rails/action_controller.rb
75
+ - lib/bleak_house/logger.rb
76
+ - lib/bleak_house/logger/mem_usage.rb
77
+ - lib/bleak_house/analyzer.rb
78
+ - lib/bleak_house/analyzer/analyzer.rb
79
+ - install.rb
80
+ - init.rb
81
+ - ext/bleak_house/logger/snapshot.h
82
+ - ext/bleak_house/logger/snapshot.c
83
+ - ext/bleak_house/logger/extconf.rb
84
+ - CHANGELOG
85
+ - bin/bleak
86
+ test_files:
87
+ - test/unit/test_bleak_house.rb
68
88
  rdoc_options: []
69
89
 
70
90
  extra_rdoc_files: []
71
91
 
72
- executables: []
73
-
74
- extensions: []
75
-
92
+ executables:
93
+ - bleak
94
+ extensions:
95
+ - ext/bleak_house/logger/extconf.rb
76
96
  requirements: []
77
97
 
78
- dependencies: []
79
-
98
+ dependencies:
99
+ - !ruby/object:Gem::Dependency
100
+ name: ccsv
101
+ version_requirement:
102
+ version_requirements: !ruby/object:Gem::Version::Requirement
103
+ requirements:
104
+ - - ">"
105
+ - !ruby/object:Gem::Version
106
+ version: 0.0.0
107
+ version: