memory_profiler 0.9.10 → 0.9.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/memory_profiler/helpers.rb +4 -1
- data/lib/memory_profiler/reporter.rb +1 -1
- data/lib/memory_profiler/results.rb +21 -11
- data/lib/memory_profiler/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7da6190dc6c838833e47d41765b0cfff971a88fd650968126345a022b7adab9f
|
4
|
+
data.tar.gz: 99c847bf242406d438b06a9a4c747bf7200556f7380e4c93fa69476e523d0675
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 821c0b5746630a740e23570b31bc1faab53b2be90d1f53000310ca2fab122b8e254f93ae25fffa63ca95b7c350b721d62320276dada82c05712945047446a683
|
7
|
+
data.tar.gz: a354ea734d19c16510c6c76612d58ea6d830f39883ef215accbc9f3c33a3f745b55a90275cdef8779b03d1dc4779fe156a9e0bfb1aa1f1073cd03f4b54696e4f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.9.11
|
4
|
+
- Reduce memory needed for string allocation tracing @dgynn
|
5
|
+
- Use yield rather than block.call to reduce an allocation @dgynn
|
6
|
+
- Ensure string allocation locations sort consistently @dgynn
|
7
|
+
|
3
8
|
## 0.9.10
|
4
9
|
- Add better detection for stdlib "gems"
|
5
10
|
|
@@ -32,7 +32,10 @@ module MemoryProfiler
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def lookup_string(obj)
|
35
|
-
|
35
|
+
# This string is shortened to 200 characters which is what the string report shows
|
36
|
+
# The string report can still list unique strings longer than 200 characters
|
37
|
+
# separately because the object_id of the shortened string will be different
|
38
|
+
@string_cache[obj] ||= obj[0,200]
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
@@ -47,16 +47,26 @@ module MemoryProfiler
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def string_report(data, top)
|
50
|
-
data.values
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
50
|
+
grouped_strings = data.values.
|
51
|
+
keep_if { |stat| stat.string_value }.
|
52
|
+
group_by { |stat| stat.string_value.object_id }.
|
53
|
+
values
|
54
|
+
|
55
|
+
if grouped_strings.size > top
|
56
|
+
cutoff = grouped_strings.sort_by!(&:size)[-top].size
|
57
|
+
grouped_strings.keep_if { |list| list.size >= cutoff }
|
58
|
+
end
|
59
|
+
|
60
|
+
grouped_strings.
|
61
|
+
sort! { |a, b| a.size == b.size ? a[0].string_value <=> b[0].string_value : b.size <=> a.size }.
|
62
|
+
first(top).
|
63
|
+
# Return array of [string, [[location, count], [location, count], ...]
|
64
|
+
map! { |list| [list[0].string_value,
|
65
|
+
list.group_by { |stat| stat.location }.
|
66
|
+
map { |location, stat_list| [location, stat_list.size] }.
|
67
|
+
sort_by!(&:last).reverse!
|
68
|
+
]
|
69
|
+
}
|
60
70
|
end
|
61
71
|
|
62
72
|
# Output the results of the report
|
@@ -110,7 +120,7 @@ module MemoryProfiler
|
|
110
120
|
io.puts "#{title} String Report"
|
111
121
|
io.puts @colorize.line("-----------------------------------")
|
112
122
|
strings.each do |string, stats|
|
113
|
-
io.puts "#{stats.reduce(0) { |a, b| a + b[1] }.to_s.rjust(10)} #{@colorize.string((string
|
123
|
+
io.puts "#{stats.reduce(0) { |a, b| a + b[1] }.to_s.rjust(10)} #{@colorize.string((string.inspect))}"
|
114
124
|
stats.sort_by { |x, y| [-y, x] }.each do |location, count|
|
115
125
|
io.puts "#{@colorize.path(count.to_s.rjust(10))} #{location}"
|
116
126
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memory_profiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Memory profiling routines for Ruby 2.1+
|
14
14
|
email:
|
@@ -50,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
50
|
version: '0'
|
51
51
|
requirements: []
|
52
52
|
rubyforge_project:
|
53
|
-
rubygems_version: 2.7.
|
53
|
+
rubygems_version: 2.7.6
|
54
54
|
signing_key:
|
55
55
|
specification_version: 4
|
56
56
|
summary: Memory profiling routines for Ruby 2.1+
|