gem_footprint_analyzer 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +35 -0
- data/README.md +297 -371
- data/exe/analyze_requires +21 -11
- data/lib/gem_footprint_analyzer.rb +0 -2
- data/lib/gem_footprint_analyzer/analyzer.rb +6 -3
- data/lib/gem_footprint_analyzer/formatters/json.rb +14 -0
- data/lib/gem_footprint_analyzer/formatters/text.rb +50 -0
- data/lib/gem_footprint_analyzer/formatters/text_base.rb +23 -0
- data/lib/gem_footprint_analyzer/formatters/tree.rb +73 -0
- data/lib/gem_footprint_analyzer/pipe_transport.rb +4 -4
- data/lib/gem_footprint_analyzer/require_spy.rb +31 -6
- data/lib/gem_footprint_analyzer/version.rb +1 -1
- metadata +7 -4
- data/lib/gem_footprint_analyzer/json_formatter.rb +0 -8
- data/lib/gem_footprint_analyzer/text_formatter.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7545b14e023e211b25a3e178e81fea39d7875f5e3cc440e3e2c343fa3e601cd
|
4
|
+
data.tar.gz: a7c6721d973008c2c5496c93fbecb9584e040d7bc523be3bed704100dfe4eee2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b72e58bb39f7e9f9fb886c1e3639b6a38bc8332b4cb7a272a273f132d08d495eda783d858286451562840b7d27c795a352ff3d39e87a044313dc4fcb41787c35
|
7
|
+
data.tar.gz: 6d75e8a5a5c7502ebc1d19b02654a49376458feba7f1d6c2e07986234ffc614c7638d9a31844b32c0500dc769a20d0ec0c165a1c670ddc5d2fc94450dfc47110
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gem_footprint_analyzer (0.1.2)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
rake (10.5.0)
|
11
|
+
rspec (3.8.0)
|
12
|
+
rspec-core (~> 3.8.0)
|
13
|
+
rspec-expectations (~> 3.8.0)
|
14
|
+
rspec-mocks (~> 3.8.0)
|
15
|
+
rspec-core (3.8.0)
|
16
|
+
rspec-support (~> 3.8.0)
|
17
|
+
rspec-expectations (3.8.2)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.8.0)
|
20
|
+
rspec-mocks (3.8.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.8.0)
|
23
|
+
rspec-support (3.8.0)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler (~> 1.16)
|
30
|
+
gem_footprint_analyzer!
|
31
|
+
rake (~> 10.0)
|
32
|
+
rspec (~> 3.0)
|
33
|
+
|
34
|
+
BUNDLED WITH
|
35
|
+
1.16.4
|
data/README.md
CHANGED
@@ -27,388 +27,314 @@ Example usages:
|
|
27
27
|
### timeout
|
28
28
|
```
|
29
29
|
$ bundle exec analyze_requires timeout
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
GemFootprintAnalyzer (0.1.1)
|
31
|
+
|
32
|
+
Analyze results (average measured from 10 run(s))
|
33
|
+
time is the amount of time given require has taken to complete
|
34
|
+
RSS is total memory increase up to the point after the require
|
35
|
+
|
36
|
+
name time RSS after
|
37
|
+
------------------------
|
38
|
+
timeout 3ms 2734KB
|
33
39
|
```
|
34
40
|
|
35
41
|
### net/http
|
36
42
|
```
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
net/http
|
43
|
+
GemFootprintAnalyzer (0.1.1)
|
44
|
+
|
45
|
+
Analyze results (average measured from 10 run(s))
|
46
|
+
time is the amount of time given require has taken to complete
|
47
|
+
RSS is total memory increase up to the point after the require
|
48
|
+
|
49
|
+
name time RSS after
|
50
|
+
-----------------------------------------------
|
51
|
+
net/http 102ms 8605KB
|
52
|
+
net/http/backward 1ms 8605KB
|
53
|
+
net/http/proxy_delta 1ms 8510KB
|
54
|
+
net/http/responses 2ms 8474KB
|
55
|
+
net/http/response 2ms 8160KB
|
56
|
+
net/http/requests 1ms 7984KB
|
57
|
+
net/http/request 1ms 7801KB
|
58
|
+
net/http/generic_request 2ms 7745KB
|
59
|
+
net/http/header 2ms 7506KB
|
60
|
+
net/http/exceptions 1ms 7215KB
|
61
|
+
stringio 0ms 7039KB
|
62
|
+
zlib 1ms 6920KB
|
63
|
+
uri 0ms 6713KB
|
64
|
+
net/protocol 28ms 6610KB
|
65
|
+
io/wait 0ms 6610KB
|
66
|
+
timeout 1ms 6397KB
|
67
|
+
socket 12ms 6168KB
|
68
|
+
io/wait 1ms 6168KB
|
69
|
+
socket.so 2ms 5754KB
|
47
70
|
```
|
48
71
|
|
49
|
-
### activesupport/
|
72
|
+
### activesupport/time
|
50
73
|
```
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
active_support/core_ext/
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
active_support/
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
active_support/time 0.3730s 13048KB
|
291
|
-
active_support/core_ext/string/starts_ends_with 0.0004s 13172KB
|
292
|
-
active_support/core_ext/string/access 0.0005s 13172KB
|
293
|
-
active_support/core_ext/string/behavior 0.0009s 13344KB
|
294
|
-
strscan 0.0012s 13912KB
|
295
|
-
erb 0.0054s 13912KB
|
296
|
-
active_support/multibyte/unicode 0.0032s 14188KB
|
297
|
-
active_support/core_ext/string/output_safety 0.0199s 14188KB
|
298
|
-
active_support/core_ext/string/exclude 0.0004s 14192KB
|
299
|
-
active_support/core_ext/string/strip 0.0004s 14196KB
|
300
|
-
active_support/string_inquirer 0.0005s 14224KB
|
301
|
-
active_support/core_ext/string/inquiry 0.0009s 14224KB
|
302
|
-
active_support/core_ext/string/indent 0.0005s 14232KB
|
303
|
-
activesupport-5.2.1/lib/active_support/core_ext/string.rb 0.0599s 14232KB
|
304
|
-
active_support/inflector 0.0007s 14256KB
|
305
|
-
active_support/core_ext/module/introspection 0.0016s 14256KB
|
306
|
-
active_support/core_ext/module/anonymous 0.0006s 14256KB
|
307
|
-
active_support/core_ext/module/reachable 0.0008s 14260KB
|
308
|
-
active_support/core_ext/module/attribute_accessors_per_thread 0.0011s 14284KB
|
309
|
-
active_support/core_ext/module/attr_internal 0.0008s 14296KB
|
310
|
-
active_support/core_ext/module/concerning 0.0007s 14320KB
|
311
|
-
active_support/core_ext/module/remove_method 0.0007s 14324KB
|
312
|
-
activesupport-5.2.1/lib/active_support/core_ext/module.rb 0.0327s 14324KB
|
313
|
-
activesupport-5.2.1/lib/active_support/core_ext/name_error.rb 0.0004s 14360KB
|
314
|
-
active_support/core_ext/array/wrap 0.0004s 14376KB
|
315
|
-
active_support/core_ext/array/access 0.0005s 14400KB
|
316
|
-
active_support/core_ext/array/grouping 0.0006s 14416KB
|
317
|
-
active_support/array_inquirer 0.0005s 14460KB
|
318
|
-
active_support/core_ext/array/inquiry 0.0009s 14460KB
|
319
|
-
activesupport-5.2.1/lib/active_support/core_ext/array.rb 0.0141s 14460KB
|
320
|
-
active_support/core_ext/class/attribute 0.0011s 14516KB
|
321
|
-
active_support/core_ext/class/subclasses 0.0033s 14532KB
|
322
|
-
activesupport-5.2.1/lib/active_support/core_ext/class.rb 0.0083s 14532KB
|
323
|
-
active_support/core_ext/numeric/bytes 0.0005s 14544KB
|
324
|
-
active_support/core_ext/numeric/inquiry 0.0004s 14544KB
|
325
|
-
bigdecimal/util 0.0006s 14552KB
|
326
|
-
active_support/core_ext/big_decimal/conversions 0.0014s 14552KB
|
327
|
-
active_support/number_helper 0.0008s 14552KB
|
328
|
-
active_support/core_ext/numeric/conversions 0.0136s 14552KB
|
329
|
-
activesupport-5.2.1/lib/active_support/core_ext/numeric.rb 0.0220s 14552KB
|
330
|
-
activesupport-5.2.1/lib/active_support/core_ext/load_error.rb 0.0003s 14552KB
|
331
|
-
activesupport-5.2.1/lib/active_support/core_ext/uri.rb 0.0005s 14552KB
|
332
|
-
active_support/core_ext/integer/multiple 0.0004s 14552KB
|
333
|
-
active_support/core_ext/integer/inflections 0.0005s 14556KB
|
334
|
-
activesupport-5.2.1/lib/active_support/core_ext/integer.rb 0.0083s 14556KB
|
335
|
-
active_support/core_ext/hash/compact 0.0004s 14556KB
|
336
|
-
active_support/core_ext/hash/reverse_merge 0.0004s 14556KB
|
337
|
-
active_support/core_ext/hash/conversions 0.0055s 14556KB
|
338
|
-
active_support/hash_with_indifferent_access 0.0014s 14608KB
|
339
|
-
active_support/core_ext/hash/indifferent_access 0.0018s 14608KB
|
340
|
-
active_support/core_ext/hash/transform_values 0.0005s 14612KB
|
341
|
-
activesupport-5.2.1/lib/active_support/core_ext/hash.rb 0.0236s 14612KB
|
342
|
-
fileutils 0.0073s 15424KB
|
343
|
-
active_support/core_ext/file/atomic 0.0079s 15424KB
|
344
|
-
activesupport-5.2.1/lib/active_support/core_ext/file.rb 0.0081s 15424KB
|
345
|
-
active_support/core_ext/range/conversions 0.0004s 15444KB
|
346
|
-
active_support/core_ext/range/include_range 0.0004s 15448KB
|
347
|
-
active_support/core_ext/range/include_time_with_zone 0.0005s 15464KB
|
348
|
-
active_support/core_ext/range/overlaps 0.0004s 15472KB
|
349
|
-
active_support/core_ext/range/each 0.0005s 15476KB
|
350
|
-
activesupport-5.2.1/lib/active_support/core_ext/range.rb 0.0164s 15476KB
|
351
|
-
active_support/core_ext/kernel/agnostics 0.0004s 15488KB
|
352
|
-
active_support/core_ext/kernel/concern 0.0007s 15488KB
|
353
|
-
activesupport-5.2.1/lib/active_support/core_ext/kernel.rb 0.0091s 15492KB
|
354
|
-
benchmark 0.0015s 15572KB
|
355
|
-
activesupport-5.2.1/lib/active_support/core_ext/benchmark.rb 0.0018s 15572KB
|
356
|
-
active_support/core_ext/object/duplicable 0.0010s 15640KB
|
357
|
-
active_support/core_ext/object/deep_dup 0.0006s 15684KB
|
358
|
-
active_support/core_ext/object/inclusion 0.0004s 15688KB
|
359
|
-
active_support/core_ext/object/conversions 0.0007s 15720KB
|
360
|
-
active_support/core_ext/object/instance_variables 0.0004s 15732KB
|
361
|
-
json/version 0.0004s 15968KB
|
362
|
-
ostruct 0.0011s 16076KB
|
363
|
-
json/generic_object 0.0018s 16076KB
|
364
|
-
json/common 0.0079s 16076KB
|
365
|
-
json/ext/parser 0.0007s 16104KB
|
366
|
-
json/ext/generator 0.0008s 16188KB
|
367
|
-
json/ext 0.0061s 16188KB
|
368
|
-
json 0.0249s 16188KB
|
369
|
-
active_support/core_ext/object/json 0.0389s 16196KB
|
370
|
-
active_support/option_merger 0.0008s 16252KB
|
371
|
-
active_support/core_ext/object/with_options 0.0017s 16252KB
|
372
|
-
activesupport-5.2.1/lib/active_support/core_ext/object.rb 0.0667s 16252KB
|
373
|
-
activesupport-5.2.1/lib/active_support/core_ext/marshal.rb 0.0004s 16272KB
|
374
|
-
activesupport-5.2.1/lib/active_support/core_ext/enumerable.rb 0.0009s 16300KB
|
375
|
-
activesupport-5.2.1/lib/active_support/core_ext/securerandom.rb 0.0005s 16332KB
|
376
|
-
activesupport-5.2.1/lib/active_support/core_ext/big_decimal.rb 0.0003s 16348KB
|
377
|
-
active_support/core_ext 0.3828s 16348KB
|
378
|
-
--------------------------------------------------------------------------------------
|
379
|
-
active_support/all 1.4652s 16348KB
|
74
|
+
GemFootprintAnalyzer (0.1.1)
|
75
|
+
|
76
|
+
Analyze results (average measured from 10 run(s))
|
77
|
+
time is the amount of time given require has taken to complete
|
78
|
+
RSS is total memory increase up to the point after the require
|
79
|
+
|
80
|
+
name time RSS after
|
81
|
+
-------------------------------------------------------------------------------------
|
82
|
+
active_support/time 1018ms 13511KB
|
83
|
+
active_support/core_ext/string/zones 5ms 13511KB
|
84
|
+
active_support/core_ext/time/zones 0ms 13511KB
|
85
|
+
active_support/core_ext/string/conversions 0ms 13456KB
|
86
|
+
active_support/core_ext/string/conversions 5ms 13451KB
|
87
|
+
active_support/core_ext/time/calculations 0ms 13451KB
|
88
|
+
date 0ms 13443KB
|
89
|
+
active_support/core_ext/numeric/time 0ms 13416KB
|
90
|
+
active_support/core_ext/integer/time 21ms 13413KB
|
91
|
+
active_support/core_ext/numeric/time 16ms 13413KB
|
92
|
+
active_support/core_ext/date/acts_like 0ms 13413KB
|
93
|
+
active_support/core_ext/date/calculations 0ms 13376KB
|
94
|
+
active_support/core_ext/time/acts_like 0ms 13371KB
|
95
|
+
active_support/core_ext/time/calculations 0ms 13364KB
|
96
|
+
active_support/duration 0ms 13364KB
|
97
|
+
active_support/duration 0ms 13351KB
|
98
|
+
active_support/core_ext/date_time 54ms 13339KB
|
99
|
+
active_support/core_ext/date_time/conversions 17ms 13339KB
|
100
|
+
active_support/values/time_zone 0ms 13339KB
|
101
|
+
active_support/core_ext/date_time/calculations 0ms 13326KB
|
102
|
+
active_support/core_ext/time/conversions 0ms 13323KB
|
103
|
+
active_support/inflector/methods 0ms 13322KB
|
104
|
+
date 0ms 13317KB
|
105
|
+
active_support/core_ext/date_time/compatibility 5ms 13300KB
|
106
|
+
active_support/core_ext/module/redefine_method 0ms 13300KB
|
107
|
+
active_support/core_ext/date_and_time/compatibility 0ms 13287KB
|
108
|
+
active_support/core_ext/date_time/calculations 0ms 13282KB
|
109
|
+
active_support/core_ext/date_time/blank 1ms 13278KB
|
110
|
+
date 0ms 13278KB
|
111
|
+
active_support/core_ext/date_time/acts_like 5ms 13264KB
|
112
|
+
active_support/core_ext/object/acts_like 0ms 13264KB
|
113
|
+
date 0ms 13252KB
|
114
|
+
active_support/core_ext/date 42ms 13247KB
|
115
|
+
active_support/core_ext/date/zones 0ms 13247KB
|
116
|
+
active_support/core_ext/date/conversions 13ms 13241KB
|
117
|
+
active_support/core_ext/module/redefine_method 0ms 13241KB
|
118
|
+
active_support/core_ext/date/zones 0ms 13231KB
|
119
|
+
active_support/inflector/methods 0ms 13227KB
|
120
|
+
date 0ms 13221KB
|
121
|
+
active_support/core_ext/date/calculations 0ms 13204KB
|
122
|
+
active_support/core_ext/date/blank 1ms 13201KB
|
123
|
+
date 0ms 13201KB
|
124
|
+
active_support/core_ext/date/acts_like 1ms 13197KB
|
125
|
+
active_support/core_ext/object/acts_like 0ms 13197KB
|
126
|
+
active_support/core_ext/time 817ms 13185KB
|
127
|
+
active_support/core_ext/time/zones 0ms 13185KB
|
128
|
+
active_support/core_ext/time/conversions 0ms 13172KB
|
129
|
+
active_support/core_ext/time/compatibility 6ms 13170KB
|
130
|
+
active_support/core_ext/module/redefine_method 1ms 13170KB
|
131
|
+
active_support/core_ext/date_and_time/compatibility 0ms 13147KB
|
132
|
+
active_support/core_ext/time/calculations 779ms 13142KB
|
133
|
+
active_support/core_ext/date/calculations 30ms 13142KB
|
134
|
+
active_support/core_ext/date_and_time/calculations 0ms 13142KB
|
135
|
+
active_support/core_ext/time/zones 0ms 13124KB
|
136
|
+
active_support/core_ext/date/zones 5ms 13119KB
|
137
|
+
active_support/core_ext/date_and_time/zones 0ms 13119KB
|
138
|
+
date 0ms 13107KB
|
139
|
+
active_support/core_ext/object/acts_like 0ms 13094KB
|
140
|
+
active_support/duration 0ms 13092KB
|
141
|
+
date 0ms 13088KB
|
142
|
+
active_support/core_ext/date_and_time/calculations 3ms 13058KB
|
143
|
+
active_support/core_ext/object/try 1ms 13058KB
|
144
|
+
delegate 0ms 13058KB
|
145
|
+
active_support/core_ext/time/zones 10ms 12970KB
|
146
|
+
active_support/core_ext/date_and_time/zones 1ms 12970KB
|
147
|
+
active_support/core_ext/time/acts_like 0ms 12900KB
|
148
|
+
active_support/time_with_zone 0ms 12890KB
|
149
|
+
active_support/time_with_zone 22ms 12858KB
|
150
|
+
active_support/core_ext/date_and_time/compatibility 6ms 12858KB
|
151
|
+
active_support/core_ext/module/attribute_accessors 5ms 12858KB
|
152
|
+
active_support/core_ext/regexp 0ms 12858KB
|
153
|
+
active_support/core_ext/array/extract_options 0ms 12775KB
|
154
|
+
active_support/core_ext/object/acts_like 0ms 12746KB
|
155
|
+
active_support/values/time_zone 0ms 12739KB
|
156
|
+
active_support/duration 0ms 12732KB
|
157
|
+
active_support/core_ext/time/conversions 219ms 12490KB
|
158
|
+
active_support/values/time_zone 215ms 12490KB
|
159
|
+
active_support/core_ext/object/blank 0ms 12490KB
|
160
|
+
concurrent/map 0ms 12439KB
|
161
|
+
tzinfo 200ms 12437KB
|
162
|
+
tzinfo/country_timezone 1ms 12437KB
|
163
|
+
tzinfo/country 1ms 12369KB
|
164
|
+
thread_safe 0ms 12369KB
|
165
|
+
tzinfo/zoneinfo_country_info 0ms 12275KB
|
166
|
+
tzinfo/ruby_country_info 1ms 12266KB
|
167
|
+
tzinfo/country_info 1ms 12214KB
|
168
|
+
tzinfo/country_index_definition 0ms 12196KB
|
169
|
+
tzinfo/timezone_proxy 1ms 12156KB
|
170
|
+
tzinfo/linked_timezone 1ms 12126KB
|
171
|
+
tzinfo/data_timezone 0ms 12083KB
|
172
|
+
tzinfo/info_timezone 0ms 12067KB
|
173
|
+
tzinfo/timezone 40ms 12017KB
|
174
|
+
thread_safe/cache 7ms 12017KB
|
175
|
+
thread_safe/mri_cache_backend 2ms 12017KB
|
176
|
+
thread_safe/non_concurrent_cache_backend 1ms 12017KB
|
177
|
+
thread 0ms 11934KB
|
178
|
+
thread_safe 11ms 11846KB
|
179
|
+
thread_safe/synchronized_delegator 5ms 11846KB
|
180
|
+
monitor 0ms 11846KB
|
181
|
+
delegate 0ms 11791KB
|
182
|
+
thread_safe/version 0ms 11782KB
|
183
|
+
set 0ms 11764KB
|
184
|
+
date 0ms 11763KB
|
185
|
+
tzinfo/timezone_period 1ms 11679KB
|
186
|
+
tzinfo/zoneinfo_data_source 2ms 11641KB
|
187
|
+
tzinfo/ruby_data_source 1ms 11597KB
|
188
|
+
tzinfo/data_source 1ms 11569KB
|
189
|
+
thread 0ms 11569KB
|
190
|
+
tzinfo/zoneinfo_timezone_info 1ms 11553KB
|
191
|
+
tzinfo/transition_data_timezone_info 1ms 11498KB
|
192
|
+
tzinfo/linked_timezone_info 0ms 11456KB
|
193
|
+
tzinfo/data_timezone_info 0ms 11440KB
|
194
|
+
tzinfo/timezone_info 0ms 11431KB
|
195
|
+
tzinfo/timezone_index_definition 0ms 11424KB
|
196
|
+
tzinfo/timezone_transition_definition 1ms 11416KB
|
197
|
+
tzinfo/timezone_transition 1ms 11400KB
|
198
|
+
tzinfo/timezone_offset 1ms 11388KB
|
199
|
+
tzinfo/timezone_definition 0ms 11367KB
|
200
|
+
tzinfo/time_or_datetime 5ms 11353KB
|
201
|
+
time 0ms 11353KB
|
202
|
+
date 0ms 11344KB
|
203
|
+
tzinfo/offset_rationals 1ms 11306KB
|
204
|
+
tzinfo/ruby_core_support 1ms 11263KB
|
205
|
+
date 0ms 11263KB
|
206
|
+
active_support/inflector/methods 0ms 11081KB
|
207
|
+
active_support/duration 442ms 11070KB
|
208
|
+
active_support/deprecation 0ms 11070KB
|
209
|
+
active_support/core_ext/string/filters 1ms 11042KB
|
210
|
+
active_support/core_ext/object/acts_like 0ms 11034KB
|
211
|
+
active_support/core_ext/module/delegation 0ms 11030KB
|
212
|
+
active_support/core_ext/array/conversions 419ms 11026KB
|
213
|
+
active_support/core_ext/object/to_query 0ms 11026KB
|
214
|
+
active_support/core_ext/object/to_param 1ms 11013KB
|
215
|
+
active_support/core_ext/object/to_query 1ms 11013KB
|
216
|
+
cgi 0ms 11013KB
|
217
|
+
active_support/core_ext/string/inflections 0ms 10974KB
|
218
|
+
active_support/core_ext/hash/keys 1ms 10967KB
|
219
|
+
active_support/xml_mini 385ms 10915KB
|
220
|
+
active_support/xml_mini/rexml 20ms 10915KB
|
221
|
+
stringio 0ms 10915KB
|
222
|
+
active_support/core_ext/object/blank 5ms 10910KB
|
223
|
+
concurrent/map 0ms 10910KB
|
224
|
+
active_support/core_ext/regexp 0ms 10890KB
|
225
|
+
active_support/core_ext/kernel/reporting 1ms 10861KB
|
226
|
+
active_support/core_ext/date_time/calculations 1ms 10816KB
|
227
|
+
date 0ms 10816KB
|
228
|
+
active_support/core_ext/string/inflections 316ms 10741KB
|
229
|
+
active_support/inflector/transliterate 10ms 10741KB
|
230
|
+
active_support/i18n 0ms 10741KB
|
231
|
+
active_support/core_ext/string/multibyte 1ms 10721KB
|
232
|
+
active_support/multibyte 0ms 10721KB
|
233
|
+
active_support/inflector/methods 298ms 10675KB
|
234
|
+
active_support/core_ext/regexp 0ms 10675KB
|
235
|
+
active_support/inflections 283ms 10660KB
|
236
|
+
active_support/inflector/inflections 281ms 10660KB
|
237
|
+
active_support/deprecation 96ms 10660KB
|
238
|
+
active_support/core_ext/module/deprecation 1ms 10660KB
|
239
|
+
active_support/deprecation/proxy_wrappers 1ms 10406KB
|
240
|
+
active_support/core_ext/regexp 0ms 10406KB
|
241
|
+
active_support/deprecation/method_wrappers 6ms 10334KB
|
242
|
+
active_support/core_ext/array/extract_options 1ms 10334KB
|
243
|
+
active_support/core_ext/module/aliasing 1ms 10312KB
|
244
|
+
active_support/deprecation/constant_accessor 1ms 10298KB
|
245
|
+
active_support/deprecation/reporting 1ms 10286KB
|
246
|
+
rbconfig 0ms 10286KB
|
247
|
+
active_support/deprecation/behaviors 26ms 10247KB
|
248
|
+
active_support/notifications 25ms 10247KB
|
249
|
+
active_support/per_thread_registry 1ms 10247KB
|
250
|
+
active_support/core_ext/module/delegation 0ms 10247KB
|
251
|
+
active_support/notifications/fanout 6ms 10200KB
|
252
|
+
concurrent/map 0ms 10200KB
|
253
|
+
mutex_m 1ms 10186KB
|
254
|
+
active_support/notifications/instrumenter 2ms 10164KB
|
255
|
+
securerandom 1ms 10164KB
|
256
|
+
active_support/deprecation/instance_delegator 5ms 10052KB
|
257
|
+
active_support/core_ext/module/delegation 0ms 10052KB
|
258
|
+
active_support/core_ext/kernel/singleton_class 1ms 10033KB
|
259
|
+
singleton 1ms 10026KB
|
260
|
+
active_support/i18n 48ms 9995KB
|
261
|
+
i18n/config 1ms 9995KB
|
262
|
+
set 0ms 9995KB
|
263
|
+
active_support/lazy_load_hooks 1ms 9914KB
|
264
|
+
i18n 20ms 9886KB
|
265
|
+
i18n/interpolate/ruby 1ms 9886KB
|
266
|
+
i18n/exceptions 1ms 9765KB
|
267
|
+
cgi 0ms 9765KB
|
268
|
+
i18n/version 0ms 9620KB
|
269
|
+
concurrent/map 0ms 9598KB
|
270
|
+
active_support/core_ext/hash/slice 1ms 9491KB
|
271
|
+
active_support/core_ext/hash/except 0ms 9425KB
|
272
|
+
active_support/core_ext/hash/deep_merge 1ms 9403KB
|
273
|
+
active_support/core_ext/regexp 0ms 9326KB
|
274
|
+
active_support/core_ext/array/prepend_and_append 0ms 9308KB
|
275
|
+
concurrent/map 102ms 9282KB
|
276
|
+
concurrent/collection/map/mri_map_backend 6ms 9282KB
|
277
|
+
concurrent/collection/map/non_concurrent_map_backend 1ms 9282KB
|
278
|
+
concurrent/constants 0ms 9282KB
|
279
|
+
thread 0ms 9021KB
|
280
|
+
concurrent/synchronization 79ms 8911KB
|
281
|
+
concurrent/synchronization/lock 1ms 8911KB
|
282
|
+
concurrent/synchronization/condition 1ms 8835KB
|
283
|
+
concurrent/synchronization/lockable_object 1ms 8729KB
|
284
|
+
concurrent/synchronization/truffle_lockable_object 0ms 8659KB
|
285
|
+
concurrent/synchronization/rbx_lockable_object 1ms 8619KB
|
286
|
+
concurrent/synchronization/jruby_lockable_object 0ms 8567KB
|
287
|
+
concurrent/synchronization/mri_lockable_object 1ms 8532KB
|
288
|
+
concurrent/synchronization/abstract_lockable_object 1ms 8468KB
|
289
|
+
concurrent/synchronization/volatile 0ms 8412KB
|
290
|
+
concurrent/synchronization/object 1ms 8359KB
|
291
|
+
concurrent/synchronization/truffle_object 1ms 8238KB
|
292
|
+
concurrent/synchronization/rbx_object 1ms 8188KB
|
293
|
+
concurrent/synchronization/jruby_object 1ms 8124KB
|
294
|
+
concurrent/synchronization/mri_object 1ms 8076KB
|
295
|
+
concurrent/utility/native_extension_loader 1ms 8000KB
|
296
|
+
concurrent/utility/engine 0ms 8000KB
|
297
|
+
concurrent/synchronization/abstract_object 0ms 7898KB
|
298
|
+
concurrent/utility/engine 1ms 7836KB
|
299
|
+
concurrent/constants 0ms 7749KB
|
300
|
+
thread 0ms 7675KB
|
301
|
+
active_support/core_ext/module/delegation 7ms 7019KB
|
302
|
+
active_support/core_ext/regexp 0ms 7019KB
|
303
|
+
set 0ms 6888KB
|
304
|
+
bigdecimal 1ms 6718KB
|
305
|
+
base64 1ms 6492KB
|
306
|
+
time 0ms 6321KB
|
307
|
+
active_support/core_ext/time/acts_like 1ms 5086KB
|
308
|
+
active_support/core_ext/object/acts_like 0ms 5086KB
|
309
|
+
time 4ms 4698KB
|
310
|
+
date 0ms 4698KB
|
311
|
+
date 4ms 3610KB
|
312
|
+
date_core 2ms 3610KB
|
380
313
|
```
|
381
314
|
|
382
315
|
### archfiend
|
383
316
|
```
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
archfiend/
|
403
|
-
archfiend/
|
404
|
-
|
405
|
-
archfiend/logging/json_formatter 0.0007s 6468KB
|
406
|
-
archfiend/logging/multi_logger 0.0008s 6488KB
|
407
|
-
archfiend/shared_loop/runnable 0.0007s 6488KB
|
408
|
-
archfiend/thread_loop 0.0008s 6528KB
|
409
|
-
archfiend/subprocess_loop 0.0010s 6568KB
|
410
|
-
---------------------------------------------------------
|
411
|
-
archfiend 0.1212s 6568KB
|
317
|
+
GemFootprintAnalyzer (0.1.1)
|
318
|
+
|
319
|
+
Analyze results (average measured from 10 run(s))
|
320
|
+
time is the amount of time given require has taken to complete
|
321
|
+
RSS is total memory increase up to the point after the require
|
322
|
+
|
323
|
+
name time RSS after
|
324
|
+
----------------------------------------------------------
|
325
|
+
archfiend 62ms 6658KB
|
326
|
+
archfiend/subprocess_loop 1ms 6658KB
|
327
|
+
archfiend/thread_loop 1ms 6345KB
|
328
|
+
archfiend/shared_loop/runnable 1ms 6150KB
|
329
|
+
archfiend/logging/multi_logger 1ms 6012KB
|
330
|
+
archfiend/logging/default_formatter 1ms 5816KB
|
331
|
+
archfiend/logging/base_formatter 1ms 5640KB
|
332
|
+
archfiend/logging 5ms 5420KB
|
333
|
+
logger 4ms 5420KB
|
334
|
+
monitor 0ms 5420KB
|
335
|
+
archfiend/application 3ms 3942KB
|
336
|
+
archfiend/version 1ms 2395KB
|
337
|
+
forwardable 0ms 1858KB
|
412
338
|
```
|
413
339
|
|
414
340
|
## Contributing
|
data/exe/analyze_requires
CHANGED
@@ -2,25 +2,30 @@
|
|
2
2
|
require 'gem_footprint_analyzer'
|
3
3
|
require 'optparse'
|
4
4
|
|
5
|
-
options =
|
6
|
-
options
|
7
|
-
options
|
5
|
+
options = {}
|
6
|
+
options[:runs] = 10
|
7
|
+
options[:debug] = false
|
8
|
+
options[:formatter] = 'tree'
|
8
9
|
|
9
10
|
opts_parser = OptionParser.new do |opts|
|
10
11
|
script_name = "bundle exec #{File.basename($0)}"
|
11
|
-
opts.banner = "
|
12
|
+
opts.banner = "GemFootprintAnalyzer (#{GemFootprintAnalyzer::VERSION})"
|
13
|
+
opts.banner += "\nUsage: #{script_name} library_to_analyze [require]"
|
12
14
|
|
13
|
-
opts.on('-f', '--formatter FORMATTER', %w[json text], 'Format output using selected formatter') do |formatter|
|
14
|
-
|
15
|
-
options.formatter = GemFootprintAnalyzer::JsonFormatter
|
16
|
-
end
|
15
|
+
opts.on('-f', '--formatter FORMATTER', %w[json text tree], 'Format output using selected formatter (json text tree)') do |formatter|
|
16
|
+
options[:formatter] = formatter
|
17
17
|
end
|
18
18
|
|
19
19
|
opts.on('-n', '--runs-num NUMBER', OptParse::DecimalInteger, 'Number of runs for avergae') do |runs|
|
20
20
|
if runs < 1
|
21
21
|
fail OptionParser::InvalidArgument, 'must be a number greater than 0'
|
22
22
|
end
|
23
|
-
options
|
23
|
+
options[:runs] = runs
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on('-d', '--debug', 'Show debug information') do |debug|
|
27
|
+
opts.banner += "\n(#{File.expand_path(File.join(File.dirname(__FILE__), '..'))})" if debug
|
28
|
+
options[:debug] = debug
|
24
29
|
end
|
25
30
|
|
26
31
|
opts.on_tail('-h', '--help', 'Show this message') do
|
@@ -35,8 +40,13 @@ if ARGV.size < 1
|
|
35
40
|
exit 1
|
36
41
|
end
|
37
42
|
|
38
|
-
requires_list_average = GemFootprintAnalyzer::AverageRunner.new(options
|
43
|
+
requires_list_average = GemFootprintAnalyzer::AverageRunner.new(options[:runs]) do
|
39
44
|
GemFootprintAnalyzer::Analyzer.new.test_library(*ARGV)
|
40
45
|
end.run
|
41
46
|
|
42
|
-
|
47
|
+
require 'gem_footprint_analyzer/formatters/text'
|
48
|
+
require 'gem_footprint_analyzer/formatters/tree'
|
49
|
+
require 'gem_footprint_analyzer/formatters/json'
|
50
|
+
|
51
|
+
formatter = GemFootprintAnalyzer::Formatters.const_get(options[:formatter].capitalize)
|
52
|
+
puts formatter.new(options).format(requires_list_average)
|
@@ -2,8 +2,6 @@ require 'gem_footprint_analyzer/version'
|
|
2
2
|
require 'gem_footprint_analyzer/pipe_transport'
|
3
3
|
require 'gem_footprint_analyzer/require_spy'
|
4
4
|
require 'gem_footprint_analyzer/analyzer'
|
5
|
-
require 'gem_footprint_analyzer/text_formatter'
|
6
|
-
require 'gem_footprint_analyzer/json_formatter'
|
7
5
|
require 'gem_footprint_analyzer/average_runner'
|
8
6
|
|
9
7
|
module GemFootprintAnalyzer
|
@@ -37,9 +37,10 @@ module GemFootprintAnalyzer
|
|
37
37
|
requires = []
|
38
38
|
while (msg, payload = parent_transport.read_one_command)
|
39
39
|
if msg == :require
|
40
|
-
curr_rss = rss(process_id)
|
41
|
-
name, time = payload
|
42
|
-
|
40
|
+
curr_rss = rss(process_id) - base_rss
|
41
|
+
name, parent_name, time = payload
|
42
|
+
|
43
|
+
requires << {name: name, parent_name: parent_name, time: Float(time) * 1000, rss: curr_rss}
|
43
44
|
elsif msg == :already_required
|
44
45
|
elsif msg == :ready
|
45
46
|
unless base_rss
|
@@ -52,6 +53,8 @@ module GemFootprintAnalyzer
|
|
52
53
|
exit 1
|
53
54
|
elsif msg == :done
|
54
55
|
break
|
56
|
+
else
|
57
|
+
fail "Unknown message: #{msg} (#{payload.inspect})"
|
55
58
|
end
|
56
59
|
end
|
57
60
|
requires
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative 'text_base'
|
2
|
+
|
3
|
+
module GemFootprintAnalyzer
|
4
|
+
module Formatters
|
5
|
+
class Text < TextBase
|
6
|
+
TABULATION = ' '.freeze
|
7
|
+
NEWLINE = "\n".freeze
|
8
|
+
|
9
|
+
def format(requires_list)
|
10
|
+
return if requires_list.size == 1
|
11
|
+
entries_num = requires_list.size
|
12
|
+
lines = []
|
13
|
+
longest_name_length = requires_list.map { |el| el[:name]&.length }.compact.max
|
14
|
+
|
15
|
+
lines << [format_name('name', longest_name_length, false), ' time ', 'RSS after'].join(' ')
|
16
|
+
lines << dash(longest_name_length + 22) if requires_list.size > 2
|
17
|
+
|
18
|
+
requires_list.each_with_index do |entry, i|
|
19
|
+
next if i.zero?
|
20
|
+
|
21
|
+
last_element = (i == entries_num - 1)
|
22
|
+
|
23
|
+
name, time, rss = entry.values_at(:name, :time, :rss)
|
24
|
+
lines << dash(longest_name_length + 22) if last_element
|
25
|
+
lines << [format_name(name, longest_name_length, last_element), format_time(time), format_rss(rss)].join(' ')
|
26
|
+
end
|
27
|
+
info + lines.join(NEWLINE)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def format_name(name, longest_name_length, last_element = false)
|
33
|
+
left_just_size = longest_name_length + 3
|
34
|
+
left_just_size += TABULATION.size if last_element
|
35
|
+
tabulation = last_element ? '' : TABULATION
|
36
|
+
tabulation + name.ljust(left_just_size)
|
37
|
+
end
|
38
|
+
|
39
|
+
def format_time(time)
|
40
|
+
value = time.is_a?(Hash) ? time[:mean] : time
|
41
|
+
"%4dms" % value.round
|
42
|
+
end
|
43
|
+
|
44
|
+
def format_rss(rss)
|
45
|
+
value = rss.is_a?(Hash) ? rss[:mean] : rss
|
46
|
+
"%6dKB" % value
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module GemFootprintAnalyzer
|
2
|
+
module Formatters
|
3
|
+
class TextBase
|
4
|
+
def initialize(options={})
|
5
|
+
@options = options
|
6
|
+
end
|
7
|
+
|
8
|
+
def info
|
9
|
+
lines = []
|
10
|
+
lines << "GemFootprintAnalyzer (#{GemFootprintAnalyzer::VERSION})\n"
|
11
|
+
lines << "Analyze results (average measured from #{@options[:runs]} run(s))"
|
12
|
+
lines << 'time is the amount of time given require has taken to complete'
|
13
|
+
lines << 'RSS is total memory increase up to the point after the require'
|
14
|
+
lines << "\n"
|
15
|
+
lines.join("\n")
|
16
|
+
end
|
17
|
+
|
18
|
+
def dash(length)
|
19
|
+
'-' * length
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module GemFootprintAnalyzer
|
2
|
+
module Formatters
|
3
|
+
class Tree < TextBase
|
4
|
+
INDENT = ' '.freeze
|
5
|
+
|
6
|
+
class Entry
|
7
|
+
def initialize(entry_hash, options={})
|
8
|
+
@entry_hash = entry_hash
|
9
|
+
@options = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def name
|
13
|
+
@entry_hash[:name]
|
14
|
+
end
|
15
|
+
|
16
|
+
def parent
|
17
|
+
@entry_hash[:parent_name]
|
18
|
+
end
|
19
|
+
|
20
|
+
def time
|
21
|
+
time = @entry_hash.dig(:time, :mean)&.round
|
22
|
+
end
|
23
|
+
|
24
|
+
def rss
|
25
|
+
@entry_hash.dig(:rss, :mean)&.round
|
26
|
+
end
|
27
|
+
|
28
|
+
def formatted_name
|
29
|
+
"#{name}#{debug_parent}"
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def debug_parent
|
35
|
+
return unless @options[:debug]
|
36
|
+
|
37
|
+
"(#{parent})"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def format(requires_list)
|
42
|
+
return if requires_list.size == 1
|
43
|
+
|
44
|
+
entries = requires_list.last(requires_list.size - 1).map { |entry_hash| Entry.new(entry_hash, @options) }
|
45
|
+
|
46
|
+
root = entries.last
|
47
|
+
indent_levels = {root.name => 0}
|
48
|
+
|
49
|
+
|
50
|
+
(entries - [root]).reverse.each do |entry|
|
51
|
+
indent_levels[entry.name] ||= indent_levels.fetch(entry.parent, 0) + 1
|
52
|
+
end
|
53
|
+
|
54
|
+
max_name_length = entries.map { |e| e.formatted_name.length }.max
|
55
|
+
max_indent = indent_levels.values.max
|
56
|
+
|
57
|
+
ljust_value = max_name_length + (max_indent * INDENT.size) + 1
|
58
|
+
|
59
|
+
|
60
|
+
lines = entries.reverse.map do |entry|
|
61
|
+
indent = INDENT * indent_levels[entry.name]
|
62
|
+
time = "%5dms" % entry.time
|
63
|
+
rss = "%7dKB" % entry.rss
|
64
|
+
|
65
|
+
"#{indent}#{entry.formatted_name}".ljust(ljust_value) + time + rss
|
66
|
+
end
|
67
|
+
lines.unshift(dash(ljust_value + 16))
|
68
|
+
lines.unshift('name'.ljust(ljust_value + 2) + 'time' + ' RSS after')
|
69
|
+
info + lines.join("\n")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -13,8 +13,8 @@ module GemFootprintAnalyzer
|
|
13
13
|
[:done, nil]
|
14
14
|
when /\Aack\z/
|
15
15
|
[:ack, nil]
|
16
|
-
when /\Arq: "([^"]+)",(.+)\z/
|
17
|
-
[:require, [$1, $2]]
|
16
|
+
when /\Arq: "([^"]+)","([^"]*)",(.+)\z/
|
17
|
+
[:require, [$1, $2, $3]]
|
18
18
|
when /\Aarq: "([^"]+)"\z/
|
19
19
|
[:already_required, $1]
|
20
20
|
when /\Astart\z/
|
@@ -55,8 +55,8 @@ module GemFootprintAnalyzer
|
|
55
55
|
@write_stream.puts 'done'
|
56
56
|
end
|
57
57
|
|
58
|
-
def report_require(library, duration)
|
59
|
-
@write_stream.puts "rq: #{library.inspect},#{duration.inspect}"
|
58
|
+
def report_require(library, source, duration)
|
59
|
+
@write_stream.puts "rq: #{library.inspect},#{source.inspect},#{duration.inspect}"
|
60
60
|
end
|
61
61
|
|
62
62
|
def report_already_required(library)
|
@@ -1,7 +1,27 @@
|
|
1
1
|
module GemFootprintAnalyzer
|
2
2
|
module RequireSpy
|
3
|
+
def self.relative_path(caller_entry, require_name=nil)
|
4
|
+
caller_file = caller_entry.split(':')[0]
|
5
|
+
if require_name
|
6
|
+
caller_dir = File.dirname(caller_file)
|
7
|
+
full_path = File.join(caller_dir, require_name)
|
8
|
+
else
|
9
|
+
full_path = caller_file
|
10
|
+
end
|
11
|
+
load_path = $LOAD_PATH.find { |lp| full_path.start_with?(lp) }
|
12
|
+
full_path.sub(/\A#{load_path}\//, '')
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.first_foreign_caller(caller)
|
16
|
+
ffc = caller.find { |c| GemFootprintAnalyzer::RequireSpy.relative_path(c) !~ /gem_footprint_analyzer/ }
|
17
|
+
if ffc
|
18
|
+
GemFootprintAnalyzer::RequireSpy.relative_path(ffc).sub(/\.rb\z/, '')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
3
22
|
def self.spy_require(interactor)
|
4
23
|
Kernel.send :alias_method, :regular_require, :require
|
24
|
+
Kernel.send :alias_method, :regular_require_relative, :require_relative
|
5
25
|
|
6
26
|
Kernel.send :define_method, :timed_exec do |&block|
|
7
27
|
start_time = Time.now.to_f
|
@@ -18,14 +38,19 @@ module GemFootprintAnalyzer
|
|
18
38
|
t = timed_exec do
|
19
39
|
result = regular_require(name)
|
20
40
|
end
|
21
|
-
|
22
|
-
|
23
|
-
interactor.report_require(name, t)
|
24
|
-
else
|
25
|
-
interactor.report_already_required(name)
|
26
|
-
end
|
41
|
+
first_foreign_caller = GemFootprintAnalyzer::RequireSpy.first_foreign_caller(caller)
|
42
|
+
interactor.report_require(name, first_foreign_caller || '', t)
|
27
43
|
result
|
28
44
|
end
|
45
|
+
|
46
|
+
# As of Ruby 2.5.1, both :require and :require_relative use an unexposed
|
47
|
+
# native method rb_safe_require, however it's challenging to plug into it
|
48
|
+
# and using original :require_relative is not really possible (it does path calculation magic)
|
49
|
+
# so instead we're redirecting :require_relative to the regular :require
|
50
|
+
Kernel.send :define_method, :require_relative do |name|
|
51
|
+
relative_path = GemFootprintAnalyzer::RequireSpy.relative_path(caller[0], name)
|
52
|
+
return require(relative_path)
|
53
|
+
end
|
29
54
|
end
|
30
55
|
end
|
31
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem_footprint_analyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maciek Dubiński
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- ".travis.yml"
|
66
66
|
- CODE_OF_CONDUCT.md
|
67
67
|
- Gemfile
|
68
|
+
- Gemfile.lock
|
68
69
|
- LICENSE.txt
|
69
70
|
- README.md
|
70
71
|
- Rakefile
|
@@ -73,10 +74,12 @@ files:
|
|
73
74
|
- lib/gem_footprint_analyzer.rb
|
74
75
|
- lib/gem_footprint_analyzer/analyzer.rb
|
75
76
|
- lib/gem_footprint_analyzer/average_runner.rb
|
76
|
-
- lib/gem_footprint_analyzer/
|
77
|
+
- lib/gem_footprint_analyzer/formatters/json.rb
|
78
|
+
- lib/gem_footprint_analyzer/formatters/text.rb
|
79
|
+
- lib/gem_footprint_analyzer/formatters/text_base.rb
|
80
|
+
- lib/gem_footprint_analyzer/formatters/tree.rb
|
77
81
|
- lib/gem_footprint_analyzer/pipe_transport.rb
|
78
82
|
- lib/gem_footprint_analyzer/require_spy.rb
|
79
|
-
- lib/gem_footprint_analyzer/text_formatter.rb
|
80
83
|
- lib/gem_footprint_analyzer/version.rb
|
81
84
|
homepage: https://github.com/irvingwashington/gem_footprint_analyzer
|
82
85
|
licenses:
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module GemFootprintAnalyzer
|
2
|
-
class TextFormatter
|
3
|
-
TABULATION = ' '.freeze
|
4
|
-
NEWLINE = "\n".freeze
|
5
|
-
|
6
|
-
def format(requires_list)
|
7
|
-
return if requires_list.size == 1
|
8
|
-
entries_num = requires_list.size
|
9
|
-
lines = []
|
10
|
-
longest_name_length = requires_list.map { |el| el[:name]&.length }.compact.max
|
11
|
-
|
12
|
-
lines << [format_name('name', longest_name_length, false), ' time ', 'RSS after'].join(' ')
|
13
|
-
lines << dash(longest_name_length) if requires_list.size > 2
|
14
|
-
|
15
|
-
requires_list.each_with_index do |entry, i|
|
16
|
-
next if i.zero?
|
17
|
-
|
18
|
-
last_element = (i == entries_num - 1)
|
19
|
-
|
20
|
-
name, time, rss = entry.values_at(:name, :time, :rss)
|
21
|
-
lines << dash(longest_name_length) if last_element
|
22
|
-
lines << [format_name(name, longest_name_length, last_element), format_time(time), format_rss(rss)].join(' ')
|
23
|
-
end
|
24
|
-
lines.join(NEWLINE)
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def format_name(name, longest_name_length, last_element = false)
|
30
|
-
left_just_size = longest_name_length + 3
|
31
|
-
left_just_size += TABULATION.size if last_element
|
32
|
-
tabulation = last_element ? '' : TABULATION
|
33
|
-
tabulation + name.ljust(left_just_size)
|
34
|
-
end
|
35
|
-
|
36
|
-
def format_time(time)
|
37
|
-
value = time.is_a?(Hash) ? time[:mean] : time
|
38
|
-
"%4dms" % value.round
|
39
|
-
end
|
40
|
-
|
41
|
-
def format_rss(rss)
|
42
|
-
value = rss.is_a?(Hash) ? rss[:mean] : rss
|
43
|
-
"%6dKB" % value
|
44
|
-
end
|
45
|
-
|
46
|
-
def dash(longest_name_length)
|
47
|
-
'-' * (longest_name_length + 22)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|