komamitsu-gc_monitor 0.0.3 → 0.0.4

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.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2009 Mitsunori Komatsu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/Manifest.txt CHANGED
@@ -2,6 +2,7 @@ History.txt
2
2
  Manifest.txt
3
3
  PostInstall.txt
4
4
  README.rdoc
5
+ LICENSE
5
6
  Rakefile
6
7
  lib/gc_monitor.rb
7
8
  script/console
data/README.rdoc CHANGED
@@ -1,8 +1,8 @@
1
1
  = GcMonitor
2
- GcMonitor is a Ruby module for monitoring GC.
2
+ GcMonitor is Ruby library for monitoring GC.
3
3
 
4
4
  == Examples
5
- If you want to monitor the specific class, you may include GcMonitor into the class.
5
+ If you want to monitor the specific class, then include GcMonitor into the class.
6
6
 
7
7
  require 'gc_monitor'
8
8
 
@@ -22,12 +22,12 @@ If you want to monitor the specific class, you may include GcMonitor into the cl
22
22
  sleep 0.5
23
23
  end
24
24
 
25
- GcMonitor.list.each{|rec| p rec} # Array of the objects not garbage collected.
25
+ GcMonitor.list.each{|rec| p rec} # Array of the remaining objects (not garbage collected).
26
26
 
27
- # You can filter the objects with using :time keyword.
27
+ # You can filter the objects by :time keyword.
28
28
  GcMonitor.list(:time => 8).each{|rec| p rec} # Only older than 8 sec.
29
29
 
30
- Then "i am released." will be printed when some Foo instancees are collected. At the last codes, array of the remaining objects will be dumped.
30
+ Then "i am released." will be printed when some Foo instances are collected. At the last code, the remaining objects will be dumped.
31
31
 
32
32
  i am released.
33
33
  :
data/lib/gc_monitor.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'thread'
2
2
 
3
3
  module GcMonitor
4
+ VERSION = '0.0.4'
5
+
4
6
  class << self
5
7
  def remaining_objects
6
8
  @remaining_objects ||= {}
@@ -71,6 +73,7 @@ module GcMonitor
71
73
 
72
74
  def included(base)
73
75
  class << base
76
+ @gc_monitor_included ||= false
74
77
  return if @gc_monitor_included
75
78
  @gc_monitor_included = true
76
79
  end
@@ -1,8 +1,119 @@
1
1
  require File.dirname(__FILE__) + '/test_helper.rb'
2
2
 
3
- class Foo
4
- attr_accessor :dummy
5
- include GcMonitor
3
+ class AP
4
+ attr_reader :something
5
+ def initialize(something)
6
+ @something = something
7
+ end
8
+ end
9
+
10
+ class AC < AP
11
+ end
12
+
13
+ class BP
14
+ attr_reader :something
15
+ def initialize(something)
16
+ @something = something
17
+ end
18
+ end
19
+
20
+ class BC < BP
21
+ attr_reader :something_else
22
+ def initialize(something_else)
23
+ @something_else = something_else
24
+ super
25
+ end
26
+ end
27
+
28
+ class CP
29
+ end
30
+
31
+ class CC < CP
32
+ attr_reader :something
33
+ def initialize(something)
34
+ @something = something
35
+ end
36
+ end
37
+
38
+ class DP
39
+ attr_reader :something
40
+ attr_accessor :value
41
+ def initialize(something)
42
+ @something = something
43
+ end
44
+ end
45
+
46
+ class DC < DP
47
+ attr_reader :something_else
48
+ def initialize(something_else)
49
+ @something_else = something_else
50
+ super
51
+ end
52
+ end
53
+
54
+ class EP
55
+ attr_reader :something
56
+ def initialize(something)
57
+ @something = something
58
+ end
59
+ end
60
+
61
+ class EC < EP
62
+ attr_reader :something_else
63
+ attr_accessor :value
64
+ def initialize(something_else)
65
+ @something_else = something_else
66
+ super
67
+ end
68
+ end
69
+
70
+ class FP
71
+ attr_accessor :value
72
+ end
73
+
74
+ class FC < FP
75
+ end
76
+
77
+ class GP
78
+ end
79
+
80
+ class GC_ < GP
81
+ attr_accessor :value
82
+ end
83
+
84
+ class HP
85
+ attr_reader :something
86
+ def initialize(something, &blk)
87
+ @something = something
88
+ @proc = blk
89
+ end
90
+
91
+ def do_it
92
+ @proc.call
93
+ end
94
+ end
95
+
96
+ class HC < HP
97
+ end
98
+
99
+ class IP
100
+ end
101
+
102
+ class IC < IP
103
+ attr_reader :something
104
+ def initialize(something, &blk)
105
+ @something = something
106
+ @proc = blk
107
+ end
108
+
109
+ def do_it
110
+ @proc.call
111
+ end
112
+ end
113
+
114
+ [AC, BC, CC, DC, EC, FC, GC_, HC, IC].each do |c|
115
+ GcMonitor.include_in_subclasses(c)
116
+ c.release_hook('puts "i am released."')
6
117
  end
7
118
 
8
119
  class TestGcMonitor < Test::Unit::TestCase
@@ -11,13 +122,50 @@ class TestGcMonitor < Test::Unit::TestCase
11
122
  end
12
123
 
13
124
  def test_exit_normal
14
- Foo.release_hook('puts "i am released."') # This is option hook, for debug.
15
- # GcMonitor.tcp_server('0.0.0.0', 4321)
125
+ GcMonitor.tcp_server('0.0.0.0', 4321)
126
+
127
+ # dummy_str = 'x' * 1 * 1024 * 1024
128
+ dummy_str = 'x' * 10
129
+ 2.times do
130
+ a = AC.new(dummy_str.clone)
131
+ assert_equal dummy_str, a.something
132
+
133
+ b = BC.new(dummy_str.clone)
134
+ assert_equal dummy_str, b.something
135
+ assert_equal dummy_str, b.something_else
136
+
137
+ c = CC.new(dummy_str.clone)
138
+ assert_equal dummy_str, c.something
139
+
140
+ d = DC.new(dummy_str.clone)
141
+ d.value = dummy_str.clone
142
+ assert_equal dummy_str, d.something
143
+ assert_equal dummy_str, d.something_else
144
+ assert_equal dummy_str, d.value
145
+
146
+ e = EC.new(dummy_str.clone)
147
+ e.value = dummy_str.clone
148
+ assert_equal dummy_str, e.something
149
+ assert_equal dummy_str, e.something_else
150
+ assert_equal dummy_str, e.value
151
+
152
+ f = FC.new
153
+ f.value = dummy_str.clone
154
+ assert_equal dummy_str, f.value
155
+
156
+ g = GC_.new
157
+ g.value = dummy_str.clone
158
+ assert_equal dummy_str, g.value
159
+
160
+ h = HC.new(dummy_str.clone) { dummy_str.clone }
161
+ assert_equal dummy_str, h.something
162
+ assert_equal dummy_str, h.do_it
163
+
164
+ i = IC.new(dummy_str.clone) { dummy_str.clone }
165
+ assert_equal dummy_str, i.something
166
+ assert_equal dummy_str, i.do_it
16
167
 
17
- 10.times do
18
- o = Foo.new
19
- o.dummy = 'x' * 10 * 1024 * 1024 # For GC.
20
- sleep 0.5
168
+ sleep 1
21
169
  end
22
170
 
23
171
  # You can filter the objects with using :time keyword.
metadata CHANGED
@@ -1,31 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: komamitsu-gc_monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
- - komamitsu
7
+ - Mitsunori Komatsu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-09 00:00:00 -07:00
12
+ date: 2009-08-11 00:00:00 -07:00
13
13
  default_executable:
14
- dependencies: []
15
-
16
- description: Ruby module for monitoring GC
17
- email: komamitsu@gmail.com
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.3.3
24
+ version:
25
+ description:
26
+ email:
27
+ - komamitsu@gmail.com
18
28
  executables: []
19
29
 
20
30
  extensions: []
21
31
 
22
- extra_rdoc_files: []
23
-
32
+ extra_rdoc_files:
33
+ - History.txt
34
+ - Manifest.txt
35
+ - PostInstall.txt
24
36
  files:
25
37
  - History.txt
26
38
  - Manifest.txt
27
39
  - PostInstall.txt
28
40
  - README.rdoc
41
+ - LICENSE
29
42
  - Rakefile
30
43
  - lib/gc_monitor.rb
31
44
  - script/console
@@ -34,9 +47,9 @@ files:
34
47
  - test/test_gc_monitor.rb
35
48
  - test/test_helper.rb
36
49
  has_rdoc: true
37
- homepage: http://github.com/komamitsu/gc_monitor
50
+ homepage:
38
51
  licenses:
39
- post_install_message:
52
+ post_install_message: PostInstall.txt
40
53
  rdoc_options:
41
54
  - --main
42
55
  - README.rdoc
@@ -56,10 +69,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
69
  version:
57
70
  requirements: []
58
71
 
59
- rubyforge_project:
72
+ rubyforge_project: gc_monitor
60
73
  rubygems_version: 1.3.5
61
74
  signing_key:
62
75
  specification_version: 2
63
- summary: Ruby module for monitoring GC
64
- test_files: []
65
-
76
+ summary: GcMonitor is Ruby library for monitoring GC.
77
+ test_files:
78
+ - test/test_helper.rb
79
+ - test/test_gc_monitor.rb