memory-profiler 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/Rakefile +11 -1
- data/lib/memory-profiler.rb +16 -16
- metadata +9 -7
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -25,7 +25,6 @@ task :gemspec do
|
|
25
25
|
gemspec.validate
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
28
|
desc "Build gem locally"
|
30
29
|
task :build => :gemspec do
|
31
30
|
system "gem#$version build #{gemspec.name}.gemspec"
|
@@ -38,6 +37,17 @@ task :install => :build do
|
|
38
37
|
system "gem#$version install pkg-#$version/#{gemspec.name}-#{gemspec.version}"
|
39
38
|
end
|
40
39
|
|
40
|
+
desc "Publish gem"
|
41
|
+
task :push => :build do
|
42
|
+
system "gem#$version push pkg-#$version/#{gemspec.name}-#{gemspec.version}"
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
desc "Generate rdoc documentation"
|
47
|
+
task :rdoc do
|
48
|
+
system "rdoc#$version #{gemspec.rdoc_options.map{|o| o =~ /\s/ ? '"'+o+'"' : o}.join(' ')}"
|
49
|
+
end
|
50
|
+
|
41
51
|
|
42
52
|
desc "Clean automatically generated files"
|
43
53
|
task :clean do
|
data/lib/memory-profiler.rb
CHANGED
@@ -3,20 +3,20 @@
|
|
3
3
|
=begin
|
4
4
|
|
5
5
|
Author: Matthew Kerwin <matthew@kerwin.net.au>
|
6
|
-
Version: 1.0
|
7
|
-
Date: 2011-01-
|
6
|
+
Version: 1.0.1
|
7
|
+
Date: 2011-01-31
|
8
8
|
|
9
9
|
|
10
|
-
Copyright 2011 Matthew Kerwin
|
10
|
+
Copyright 2011 Matthew Kerwin.
|
11
11
|
|
12
12
|
Licensed under the Apache License, Version 2.0 (the "License");
|
13
13
|
you may not use this file except in compliance with the License.
|
14
|
-
You may obtain a copy of at
|
14
|
+
You may obtain a copy of the License at
|
15
15
|
|
16
16
|
http://www.apache.org/licenses/LICENSE-2.0
|
17
17
|
|
18
18
|
Unless required by applicable law or agreed to in writing, software
|
19
|
-
distributed under the License is distributed on an "AS IS"
|
19
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
20
20
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
21
21
|
See the License for the specific language governing permissions and
|
22
22
|
limitations under the License.
|
@@ -48,7 +48,7 @@ module MemoryProfiler
|
|
48
48
|
|
49
49
|
#
|
50
50
|
# Begins an analysis thread that runs periodically, reporting to a text
|
51
|
-
# file at
|
51
|
+
# file at: /tmp/memory_profiler-<pid>.log
|
52
52
|
#
|
53
53
|
# Returns the filename used.
|
54
54
|
#
|
@@ -101,7 +101,7 @@ module MemoryProfiler
|
|
101
101
|
end
|
102
102
|
|
103
103
|
#
|
104
|
-
# Generates
|
104
|
+
# Generates an instantaneous report on the current Ruby ObjectSpace, saved to
|
105
105
|
# a text file at: /tmp/memory_profiler-<pid>-<time>.log
|
106
106
|
#
|
107
107
|
# Returns the filename used.
|
@@ -136,7 +136,7 @@ module MemoryProfiler
|
|
136
136
|
# starts the analyser, and waits for a call to #restart or #stop.
|
137
137
|
#
|
138
138
|
# Returned data is an array of:
|
139
|
-
# [
|
139
|
+
# [ [Class, current_usage, usage_delta], ... ]
|
140
140
|
#
|
141
141
|
# Options:
|
142
142
|
# :sort_by => :current # how to order classes; :current | :delta | :absdelta | :none
|
@@ -151,7 +151,7 @@ module MemoryProfiler
|
|
151
151
|
# :marshall_size => false # see ObjectSpaceAnalyser#analyse
|
152
152
|
#
|
153
153
|
def self.start(opt = {}, &block)
|
154
|
-
|
154
|
+
opt = DEFAULTS.merge(opt)
|
155
155
|
if block_given?
|
156
156
|
# get pre-block analysis of ObjectSpace
|
157
157
|
GC.start if opt[:force_gc]
|
@@ -183,7 +183,7 @@ module MemoryProfiler
|
|
183
183
|
end
|
184
184
|
|
185
185
|
#
|
186
|
-
# Stops the current analysis and
|
186
|
+
# Stops the current analysis and emits the results.
|
187
187
|
#
|
188
188
|
# See: #start
|
189
189
|
#
|
@@ -220,7 +220,7 @@ module MemoryProfiler
|
|
220
220
|
res
|
221
221
|
end
|
222
222
|
|
223
|
-
#
|
223
|
+
# => [ [Class, current, delta], ... ]
|
224
224
|
def self._delta(curr, prev, opt={}) #:nodoc:
|
225
225
|
opt = DEFAULTS.merge(opt)
|
226
226
|
|
@@ -242,7 +242,7 @@ module MemoryProfiler
|
|
242
242
|
when :absdelta
|
243
243
|
data = data.sort_by{|k,c,d| -( d.abs ) }
|
244
244
|
else
|
245
|
-
warn "
|
245
|
+
warn "MemoryProfiler: invalid option :sort_by => #{opt[:sort_by].inspect}; using :none"
|
246
246
|
opt[:limit] = -1
|
247
247
|
end
|
248
248
|
data = data[0,opt[:limit]] if opt[:limit] > 0 and opt[:limit] < data.length
|
@@ -252,7 +252,7 @@ module MemoryProfiler
|
|
252
252
|
end
|
253
253
|
|
254
254
|
#
|
255
|
-
# Formats data, such as that
|
255
|
+
# Formats data, such as that returned by #start , into a printable,
|
256
256
|
# readable string.
|
257
257
|
#
|
258
258
|
def self.format(data)
|
@@ -266,11 +266,11 @@ module MemoryProfiler
|
|
266
266
|
#
|
267
267
|
# Returns a hash mapping each Class to its usage.
|
268
268
|
#
|
269
|
-
# If opt[:marshall_size] is true, the usage is estimated using Marshall.dump() for each instance
|
269
|
+
# If opt[:marshall_size] is true, the usage is estimated using Marshall.dump() for each instance;
|
270
270
|
# otherwise it is a simple instance count.
|
271
271
|
#
|
272
272
|
# If opt[:string_debug] is true, the analyser writes a text file containing every string
|
273
|
-
# in the Ruby ObjectSpace, at: /tmp/memory_profiler-<pid>-
|
273
|
+
# in the Ruby ObjectSpace, at: /tmp/memory_profiler-<pid>-strings-<time>.log
|
274
274
|
#
|
275
275
|
# Uses opt[:only] and opt[:ignore] , as per MemoryProfiler#start
|
276
276
|
#
|
@@ -285,7 +285,7 @@ module MemoryProfiler
|
|
285
285
|
str = [] if string_debug
|
286
286
|
ObjectSpace.each_object do |o|
|
287
287
|
if res[o.class] or ((only.empty? or only.any?{|y| o.is_a? y }) and ign.none?{|x| o.is_a? x })
|
288
|
-
res[o.class] += (
|
288
|
+
res[o.class] += (marshall_size ? self.__sizeof(o) : 1)
|
289
289
|
end
|
290
290
|
str.push o.inspect if string_debug and o.class == String
|
291
291
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memory-profiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matthew Kerwin
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-31 00:00:00 +10:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -30,11 +30,11 @@ extra_rdoc_files: []
|
|
30
30
|
|
31
31
|
files:
|
32
32
|
- lib/memory-profiler.rb
|
33
|
-
- Gemfile
|
34
|
-
- README
|
35
33
|
- Rakefile
|
36
|
-
- Gemfile.lock
|
37
34
|
- LICENSE
|
35
|
+
- README
|
36
|
+
- Gemfile.lock
|
37
|
+
- Gemfile
|
38
38
|
has_rdoc: true
|
39
39
|
homepage: http://code.google.com/p/memory-profiler-ruby/
|
40
40
|
licenses:
|
@@ -46,6 +46,8 @@ rdoc_options:
|
|
46
46
|
- --main
|
47
47
|
- MemoryProfiler
|
48
48
|
- --line-numbers
|
49
|
+
- --tab-width
|
50
|
+
- "2"
|
49
51
|
require_paths:
|
50
52
|
- lib
|
51
53
|
required_ruby_version: !ruby/object:Gem::Requirement
|