allocation_tracer 0.4.2 → 0.4.3
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.
- checksums.yaml +4 -4
- data/README.md +27 -2
- data/lib/allocation_tracer.rb +2 -2
- data/lib/allocation_tracer/version.rb +1 -1
- data/spec/allocation_tracer_spec.rb +2 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dc53bab30ca77dc661da7cc1d75b0c2ac07881f
|
4
|
+
data.tar.gz: cf61afd7c08c2898d4454002679f29c024e83646
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 859f36690133321cc4de4378e115de5ecd6a0a7e0b3793fa728fe41c9c5ad4e918025337b844410c8fca43b8c310e37e0cf785ff2658843ebacc68a0e77c56c3
|
7
|
+
data.tar.gz: defdaa389a03387009e8b29b6232252349db69a035a6618ec27a462d6d45091a7a0a9dc37ef483243d34bf49d36d0b7bab010d5af9c9442a678b55d3fc182fec
|
data/README.md
CHANGED
@@ -63,7 +63,7 @@ will show
|
|
63
63
|
In this case,
|
64
64
|
* 50,000 objects are created at `test.rb:6' and
|
65
65
|
* 5 old objects created.
|
66
|
-
* 44,290 is total age of objects created at this line (average age of object created at this line is 50000
|
66
|
+
* 44,290 is total age of objects created at this line (average age of object created at this line is 44290/50000 = 0.8858).
|
67
67
|
* 0 is minimum age
|
68
68
|
* 6 is maximum age.
|
69
69
|
|
@@ -154,6 +154,31 @@ test.rb 7 50000 7 41497 0 5 0
|
|
154
154
|
|
155
155
|
(tab separated colums)
|
156
156
|
|
157
|
+
### Total Allocations / Free
|
158
|
+
|
159
|
+
Allocation tracer collects the total number of allocations and frees during the
|
160
|
+
`trace` block. After the block finishes executing, you can examine the total
|
161
|
+
number of allocations / frees per object type like this:
|
162
|
+
|
163
|
+
```ruby
|
164
|
+
require 'allocation_tracer'
|
165
|
+
|
166
|
+
ObjectSpace::AllocationTracer.trace do
|
167
|
+
1000.times {
|
168
|
+
["foo", {}]
|
169
|
+
}
|
170
|
+
end
|
171
|
+
p allocated: ObjectSpace::AllocationTracer.allocated_count_table
|
172
|
+
p freed: ObjectSpace::AllocationTracer.freed_count_table
|
173
|
+
```
|
174
|
+
|
175
|
+
The output of the script will look like this:
|
176
|
+
|
177
|
+
```
|
178
|
+
{:allocated=>{:T_NONE=>0, :T_OBJECT=>0, :T_CLASS=>0, :T_MODULE=>0, :T_FLOAT=>0, :T_STRING=>1000, :T_REGEXP=>0, :T_ARRAY=>1000, :T_HASH=>1000, :T_STRUCT=>0, :T_BIGNUM=>0, :T_FILE=>0, :T_DATA=>0, :T_MATCH=>0, :T_COMPLEX=>0, :T_RATIONAL=>0, :unknown=>0, :T_NIL=>0, :T_TRUE=>0, :T_FALSE=>0, :T_SYMBOL=>0, :T_FIXNUM=>0, :T_UNDEF=>0, :T_NODE=>0, :T_ICLASS=>0, :T_ZOMBIE=>0}}
|
179
|
+
{:freed=>{:T_NONE=>0, :T_OBJECT=>0, :T_CLASS=>0, :T_MODULE=>0, :T_FLOAT=>0, :T_STRING=>1871, :T_REGEXP=>41, :T_ARRAY=>226, :T_HASH=>7, :T_STRUCT=>41, :T_BIGNUM=>0, :T_FILE=>50, :T_DATA=>25, :T_MATCH=>47, :T_COMPLEX=>0, :T_RATIONAL=>0, :unknown=>0, :T_NIL=>0, :T_TRUE=>0, :T_FALSE=>0, :T_SYMBOL=>0, :T_FIXNUM=>0, :T_UNDEF=>0, :T_NODE=>932, :T_ICLASS=>0, :T_ZOMBIE=>0}}
|
180
|
+
```
|
181
|
+
|
157
182
|
### Lifetime table
|
158
183
|
|
159
184
|
You can collect lifetime statistics with
|
@@ -190,7 +215,7 @@ current age.
|
|
190
215
|
|
191
216
|
## Contributing
|
192
217
|
|
193
|
-
1. Fork it ( http://github.com
|
218
|
+
1. Fork it ( http://github.com/ko1/allocation_tracer/fork )
|
194
219
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
195
220
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
196
221
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/allocation_tracer.rb
CHANGED
@@ -12,7 +12,7 @@ module ObjectSpace::AllocationTracer
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.
|
15
|
+
def self.collect_lifetime_table
|
16
16
|
ObjectSpace::AllocationTracer.lifetime_table_setup true
|
17
17
|
|
18
18
|
if block_given?
|
@@ -30,7 +30,7 @@ module ObjectSpace::AllocationTracer
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def self.
|
33
|
+
def self.collect_lifetime_table_stop
|
34
34
|
ObjectSpace::AllocationTracer.stop
|
35
35
|
result = ObjectSpace::AllocationTracer.lifetime_table
|
36
36
|
ObjectSpace::AllocationTracer.lifetime_table_setup false
|
@@ -235,9 +235,9 @@ describe ObjectSpace::AllocationTracer do
|
|
235
235
|
end
|
236
236
|
end
|
237
237
|
|
238
|
-
describe 'ObjectSpace::AllocationTracer.
|
238
|
+
describe 'ObjectSpace::AllocationTracer.collect_lifetime_table' do
|
239
239
|
it 'should collect lifetime table' do
|
240
|
-
table = ObjectSpace::AllocationTracer.
|
240
|
+
table = ObjectSpace::AllocationTracer.collect_lifetime_table do
|
241
241
|
100000.times{
|
242
242
|
Object.new
|
243
243
|
''
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: allocation_tracer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi Sasada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,11 +108,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
110
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.4.
|
111
|
+
rubygems_version: 2.4.5
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: allocation_tracer gem adds ObjectSpace::AllocationTracer module.
|
115
115
|
test_files:
|
116
116
|
- spec/allocation_tracer_spec.rb
|
117
117
|
- spec/spec_helper.rb
|
118
|
-
has_rdoc:
|