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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43851e68328fcbb706622d0ac43f4f76d5d39b31c1075e16da733afd295b8298
4
- data.tar.gz: 3f9f094111649aac24a2c940eb7b4a08add6277aba99cd2273a79cfdf41b70e7
3
+ metadata.gz: d7545b14e023e211b25a3e178e81fea39d7875f5e3cc440e3e2c343fa3e601cd
4
+ data.tar.gz: a7c6721d973008c2c5496c93fbecb9584e040d7bc523be3bed704100dfe4eee2
5
5
  SHA512:
6
- metadata.gz: f9e704e8e3f493d612b161d0347c01335841dba6d7e79f0a59fae4a2e741a98b0266c3d0265cbc10f4a94cdba788d058532bc4ef49943356df6045870c0e16c3
7
- data.tar.gz: 2d8cea799faaa804496bbaf6a0b23262028df983cf04b2b9abcd680e3e3576500979fdc44869940389e3b68735ac79dcec5f42be182c713bcb70759f59fd48eb
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
- name time RSS after
31
- -----------------------------
32
- timeout 0.0032s 2140KB
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
- $ bundle exec analyze_requires net/http
38
- name time RSS after
39
- -------------------------------
40
- socket.so 0.0019s 4920KB
41
- io/wait 0.0009s 5296KB
42
- socket 0.0108s 5296KB
43
- timeout 0.0014s 5736KB
44
- zlib 0.0012s 5924KB
45
- -------------------------------
46
- net/http 0.0476s 6712KB
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/all
72
+ ### activesupport/time
50
73
  ```
51
- $ bundle exec analyze_requires activesupport active_support/all
52
- name time RSS after
53
- --------------------------------------------------------------------------------------
54
- securerandom 0.0022s 2728KB
55
- concurrent/constants 0.0005s 4168KB
56
- concurrent/utility/engine 0.0006s 4268KB
57
- concurrent/synchronization/abstract_object 0.0006s 4360KB
58
- concurrent/utility/native_extension_loader 0.0015s 5008KB
59
- concurrent/synchronization/mri_object 0.0006s 5132KB
60
- concurrent/synchronization/jruby_object 0.0006s 5172KB
61
- concurrent/synchronization/rbx_object 0.0006s 5212KB
62
- concurrent/synchronization/truffle_object 0.0007s 5312KB
63
- concurrent/synchronization/object 0.0010s 5416KB
64
- concurrent/synchronization/volatile 0.0006s 5536KB
65
- concurrent/synchronization/abstract_lockable_object 0.0007s 5656KB
66
- concurrent/synchronization/mri_lockable_object 0.0008s 5776KB
67
- concurrent/synchronization/jruby_lockable_object 0.0005s 5840KB
68
- concurrent/synchronization/rbx_lockable_object 0.0007s 5864KB
69
- concurrent/synchronization/truffle_lockable_object 0.0004s 5884KB
70
- concurrent/synchronization/lockable_object 0.0005s 5936KB
71
- concurrent/synchronization/condition 0.0007s 5984KB
72
- concurrent/synchronization/lock 0.0005s 6012KB
73
- concurrent/synchronization 0.0745s 6012KB
74
- concurrent/collection/map/non_concurrent_map_backend 0.0010s 6144KB
75
- concurrent/collection/map/mri_map_backend 0.0018s 6144KB
76
- concurrent/map 0.0894s 6144KB
77
- active_support/core_ext/array/prepend_and_append 0.0004s 6156KB
78
- active_support/core_ext/regexp 0.0004s 6180KB
79
- active_support/core_ext/hash/deep_merge 0.0005s 6280KB
80
- active_support/core_ext/hash/except 0.0005s 6304KB
81
- active_support/core_ext/hash/slice 0.0006s 6424KB
82
- i18n/version 0.0003s 6512KB
83
- i18n/exceptions 0.0012s 6688KB
84
- i18n/interpolate/ruby 0.0006s 6776KB
85
- i18n 0.0114s 6776KB
86
- active_support/lazy_load_hooks 0.0006s 6812KB
87
- i18n/config 0.0009s 6932KB
88
- active_support/i18n 0.0374s 6932KB
89
- singleton 0.0006s 6992KB
90
- active_support/core_ext/kernel/singleton_class 0.0005s 7048KB
91
- active_support/core_ext/module/delegation 0.0020s 7208KB
92
- active_support/deprecation/instance_delegator 0.0068s 7208KB
93
- active_support/notifications/instrumenter 0.0008s 7332KB
94
- mutex_m 0.0005s 7428KB
95
- active_support/notifications/fanout 0.0053s 7460KB
96
- active_support/per_thread_registry 0.0005s 7480KB
97
- active_support/notifications 0.0146s 7480KB
98
- active_support/deprecation/behaviors 0.0153s 7480KB
99
- active_support/deprecation/reporting 0.0010s 7560KB
100
- active_support/deprecation/constant_accessor 0.0007s 7688KB
101
- active_support/core_ext/module/aliasing 0.0005s 7732KB
102
- active_support/core_ext/array/extract_options 0.0004s 7748KB
103
- active_support/deprecation/method_wrappers 0.0052s 7748KB
104
- active_support/deprecation/proxy_wrappers 0.0010s 7832KB
105
- active_support/core_ext/module/deprecation 0.0005s 8276KB
106
- active_support/deprecation 0.0723s 8276KB
107
- active_support/inflector/inflections 0.2265s 8276KB
108
- active_support/inflections 0.2285s 8276KB
109
- active_support/inflector/methods 0.2426s 8284KB
110
- active_support/dependencies/autoload 0.2438s 8284KB
111
- active_support/version 0.0006s 8308KB
112
- active_support/concern 0.0007s 8620KB
113
- active_support/core_ext/module/attribute_accessors 0.0011s 8688KB
114
- concurrent/version 0.0003s 8728KB
115
- concurrent/errors 0.0006s 8768KB
116
- timeout 0.0009s 9052KB
117
- concurrent/atomic/event 0.0008s 9080KB
118
- concurrent/concern/dereferenceable 0.0006s 9116KB
119
- concurrent/concern/obligation 0.0107s 9116KB
120
- logger 0.0024s 9632KB
121
- concurrent/concern/logging 0.0029s 9632KB
122
- concurrent/executor/executor_service 0.0035s 9632KB
123
- concurrent/utility/at_exit 0.0010s 9640KB
124
- concurrent/executor/abstract_executor_service 0.0173s 9640KB
125
- concurrent/executor/serial_executor_service 0.0005s 9640KB
126
- concurrent/executor/immediate_executor 0.0263s 9640KB
127
- concurrent/delay 0.0523s 9648KB
128
- concurrent/atomic_reference/concurrent_update_error 0.0004s 9656KB
129
- concurrent/atomic_reference/direct_update 0.0005s 9672KB
130
- concurrent/atomic_reference/numeric_cas_wrapper 0.0005s 9680KB
131
- concurrent/atomic_reference/mutex_atomic 0.0054s 9680KB
132
- concurrent/atomic_reference/ruby 0.0004s 9688KB
133
- concurrent/atomic/atomic_reference 0.0179s 9688KB
134
- concurrent/utility/processor_counter 0.0012s 9728KB
135
- concurrent/configuration 0.0837s 9728KB
136
- concurrent/atomic/mutex_atomic_boolean 0.0006s 9732KB
137
- concurrent/atomic/atomic_boolean 0.0049s 9732KB
138
- concurrent/utility/native_integer 0.0006s 9800KB
139
- concurrent/atomic/mutex_atomic_fixnum 0.0013s 9800KB
140
- concurrent/atomic/atomic_fixnum 0.0093s 9800KB
141
- concurrent/atomic/cyclic_barrier 0.0010s 9816KB
142
- concurrent/atomic/mutex_count_down_latch 0.0006s 9820KB
143
- concurrent/atomic/java_count_down_latch 0.0005s 9832KB
144
- concurrent/atomic/count_down_latch 0.0091s 9832KB
145
- concurrent/atomic/read_write_lock 0.0014s 9876KB
146
- concurrent/atomic/abstract_thread_local_var 0.0006s 9920KB
147
- concurrent/atomic/ruby_thread_local_var 0.0015s 9920KB
148
- concurrent/atomic/java_thread_local_var 0.0008s 9948KB
149
- concurrent/atomic/thread_local_var 0.0145s 9956KB
150
- concurrent/atomic/reentrant_read_write_lock 0.0162s 9956KB
151
- concurrent/atomic/mutex_semaphore 0.0012s 10164KB
152
- concurrent/atomic/semaphore 0.0057s 10164KB
153
- concurrent/atomics 0.0782s 10164KB
154
- concurrent/executor/ruby_executor_service 0.0008s 10192KB
155
- concurrent/utility/monotonic_time 0.0006s 10208KB
156
- concurrent/executor/ruby_thread_pool_executor 0.0070s 10208KB
157
- concurrent/executor/thread_pool_executor 0.0076s 10208KB
158
- concurrent/executor/cached_thread_pool 0.0083s 10208KB
159
- concurrent/executor/fixed_thread_pool 0.0007s 10212KB
160
- concurrent/executor/simple_executor_service 0.0008s 10236KB
161
- concurrent/executor/indirect_immediate_executor 0.0015s 10236KB
162
- concurrent/executor/java_executor_service 0.0009s 10260KB
163
- concurrent/executor/java_single_thread_executor 0.0005s 10268KB
164
- concurrent/executor/java_thread_pool_executor 0.0007s 10292KB
165
- concurrent/executor/ruby_single_thread_executor 0.0005s 10292KB
166
- concurrent/executor/safe_task_executor 0.0006s 10292KB
167
- concurrent/executor/serialized_execution 0.0011s 10368KB
168
- concurrent/executor/serialized_execution_delegator 0.0008s 10376KB
169
- concurrent/executor/single_thread_executor 0.0006s 10380KB
170
- concurrent/collection/copy_on_write_observer_set 0.0008s 10460KB
171
- concurrent/collection/copy_on_notify_observer_set 0.0008s 10508KB
172
- concurrent/concern/observable 0.0053s 10508KB
173
- concurrent/ivar 0.0148s 10512KB
174
- concurrent/options 0.0006s 10512KB
175
- concurrent/scheduled_task 0.0203s 10512KB
176
- concurrent/collection/java_non_concurrent_priority_queue 0.0006s 10564KB
177
- concurrent/collection/ruby_non_concurrent_priority_queue 0.0008s 10564KB
178
- concurrent/collection/non_concurrent_priority_queue 0.0096s 10640KB
179
- concurrent/executor/timer_set 0.0420s 10644KB
180
- concurrent/executors 0.1153s 10644KB
181
- concurrent/agent 0.0023s 10748KB
182
- concurrent/atom 0.0012s 10768KB
183
- concurrent/thread_safe/util 0.0004s 10772KB
184
- concurrent/array 0.0019s 10772KB
185
- concurrent/hash 0.0007s 10776KB
186
- concurrent/tuple 0.0007s 10780KB
187
- concurrent/async 0.0012s 10780KB
188
- concurrent/future 0.0011s 10784KB
189
- concurrent/dataflow 0.0057s 10784KB
190
- concurrent/maybe 0.0007s 10796KB
191
- concurrent/exchanger 0.0063s 10796KB
192
- concurrent/synchronization/abstract_struct 0.0009s 10848KB
193
- concurrent/immutable_struct 0.0054s 10852KB
194
- concurrent/mutable_struct 0.0011s 10880KB
195
- concurrent/mvar 0.0011s 10884KB
196
- concurrent/promise 0.0021s 10888KB
197
- concurrent/settable_struct 0.0012s 10896KB
198
- concurrent/timer_task 0.0016s 10940KB
199
- concurrent/tvar 0.0013s 10984KB
200
- concurrent/thread_safe/synchronized_delegator 0.0007s 10984KB
201
- concurrent 0.4029s 10988KB
202
- active_support/logger_silence 0.4127s 10988KB
203
- active_support/logger_thread_safe_level 0.0006s 10996KB
204
- active_support/logger 0.4257s 11084KB
205
- active_support/core_ext/date_and_time/compatibility 0.0006s 11144KB
206
- active_support 0.6941s 11144KB
207
- date_core 0.0013s 11520KB
208
- date 0.0020s 11520KB
209
- time 0.0025s 11616KB
210
- active_support/core_ext/object/acts_like 0.0003s 11616KB
211
- active_support/core_ext/time/acts_like 0.0008s 11616KB
212
- base64 0.0005s 11768KB
213
- bigdecimal 0.0010s 11808KB
214
- active_support/multibyte 0.0004s 11812KB
215
- active_support/core_ext/string/multibyte 0.0008s 11812KB
216
- active_support/inflector/transliterate 0.0086s 11816KB
217
- active_support/core_ext/string/inflections 0.0095s 11816KB
218
- active_support/core_ext/date_time/calculations 0.0011s 11848KB
219
- active_support/core_ext/kernel/reporting 0.0008s 11888KB
220
- active_support/core_ext/object/blank 0.0017s 11888KB
221
- active_support/xml_mini/rexml 0.0113s 11888KB
222
- active_support/xml_mini 0.0429s 11888KB
223
- active_support/core_ext/hash/keys 0.0010s 11924KB
224
- active_support/core_ext/object/to_query 0.0007s 11924KB
225
- active_support/core_ext/object/to_param 0.0011s 11924KB
226
- active_support/core_ext/array/conversions 0.0638s 11924KB
227
- active_support/core_ext/string/filters 0.0007s 11936KB
228
- active_support/duration 0.0740s 11936KB
229
- tzinfo/ruby_core_support 0.0009s 12152KB
230
- tzinfo/offset_rationals 0.0006s 12196KB
231
- tzinfo/time_or_datetime 0.0012s 12224KB
232
- tzinfo/timezone_definition 0.0005s 12232KB
233
- tzinfo/timezone_offset 0.0006s 12232KB
234
- tzinfo/timezone_transition 0.0008s 12288KB
235
- tzinfo/timezone_transition_definition 0.0006s 12288KB
236
- tzinfo/timezone_index_definition 0.0005s 12288KB
237
- tzinfo/timezone_info 0.0004s 12288KB
238
- tzinfo/data_timezone_info 0.0005s 12300KB
239
- tzinfo/linked_timezone_info 0.0004s 12300KB
240
- tzinfo/transition_data_timezone_info 0.0013s 12428KB
241
- tzinfo/zoneinfo_timezone_info 0.0014s 12492KB
242
- tzinfo/data_source 0.0009s 12532KB
243
- tzinfo/ruby_data_source 0.0008s 12548KB
244
- tzinfo/zoneinfo_data_source 0.0018s 12636KB
245
- tzinfo/timezone_period 0.0009s 12672KB
246
- thread_safe/version 0.0004s 12684KB
247
- thread_safe/synchronized_delegator 0.0006s 12684KB
248
- thread_safe 0.0056s 12684KB
249
- thread_safe/non_concurrent_cache_backend 0.0007s 12720KB
250
- thread_safe/mri_cache_backend 0.0014s 12720KB
251
- thread_safe/cache 0.0026s 12720KB
252
- tzinfo/timezone 0.0171s 12720KB
253
- tzinfo/info_timezone 0.0005s 12720KB
254
- tzinfo/data_timezone 0.0004s 12724KB
255
- tzinfo/linked_timezone 0.0005s 12724KB
256
- tzinfo/timezone_proxy 0.0006s 12736KB
257
- tzinfo/country_index_definition 0.0005s 12740KB
258
- tzinfo/country_info 0.0005s 12740KB
259
- tzinfo/ruby_country_info 0.0006s 12748KB
260
- tzinfo/zoneinfo_country_info 0.0013s 12748KB
261
- tzinfo/country 0.0009s 12756KB
262
- tzinfo/country_timezone 0.0007s 12760KB
263
- tzinfo 0.1486s 12760KB
264
- active_support/values/time_zone 0.1584s 12768KB
265
- active_support/core_ext/time/conversions 0.1592s 12768KB
266
- active_support/time_with_zone 0.0026s 12868KB
267
- active_support/core_ext/date_and_time/zones 0.0004s 12868KB
268
- active_support/core_ext/time/zones 0.0014s 12868KB
269
- active_support/core_ext/object/try 0.0007s 12884KB
270
- active_support/core_ext/date_and_time/calculations 0.0023s 12884KB
271
- active_support/core_ext/date/zones 0.0005s 12884KB
272
- active_support/core_ext/date/calculations 0.0058s 12884KB
273
- active_support/core_ext/time/calculations 0.2757s 12884KB
274
- active_support/core_ext/module/redefine_method 0.0008s 12884KB
275
- active_support/core_ext/time/compatibility 0.0014s 12884KB
276
- active_support/core_ext/time 0.2999s 12888KB
277
- active_support/core_ext/date/acts_like 0.0004s 12888KB
278
- active_support/core_ext/date/blank 0.0004s 12888KB
279
- active_support/core_ext/date/conversions 0.0010s 12888KB
280
- active_support/core_ext/date 0.0134s 12904KB
281
- active_support/core_ext/date_time/acts_like 0.0005s 12904KB
282
- active_support/core_ext/date_time/blank 0.0005s 12904KB
283
- active_support/core_ext/date_time/compatibility 0.0006s 12908KB
284
- active_support/core_ext/date_time/conversions 0.0016s 12936KB
285
- active_support/core_ext/date_time 0.0145s 12936KB
286
- active_support/core_ext/numeric/time 0.0013s 12980KB
287
- active_support/core_ext/integer/time 0.0019s 12980KB
288
- active_support/core_ext/string/conversions 0.0011s 13048KB
289
- active_support/core_ext/string/zones 0.0005s 13048KB
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
- $ bundle exec analyze_requires archfiend
385
- name time RSS after
386
- ---------------------------------------------------------
387
- archfiend/version 0.0010s 1648KB
388
- archfiend/application 0.0031s 3024KB
389
- logger 0.0071s 4264KB
390
- bigdecimal 0.0035s 4668KB
391
- oj/version 0.0009s 4700KB
392
- oj/bag 0.0010s 4756KB
393
- oj/easy_hash 0.0009s 4796KB
394
- oj/error 0.0008s 4824KB
395
- ostruct 0.0026s 5540KB
396
- oj/mimic 0.0048s 5540KB
397
- oj/saj 0.0009s 5568KB
398
- oj/schandler 0.0008s 5624KB
399
- date_core 0.0029s 6096KB
400
- oj/oj 0.0139s 6428KB
401
- oj 0.0601s 6428KB
402
- archfiend/logging 0.0719s 6428KB
403
- archfiend/logging/base_formatter 0.0009s 6444KB
404
- archfiend/logging/default_formatter 0.0007s 6456KB
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 = OpenStruct.new
6
- options.runs = 10
7
- options.formatter = GemFootprintAnalyzer::TextFormatter
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 = "Usage: #{script_name} library_to_analyze [require]"
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
- if formatter == 'json'
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.runs = runs
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.runs) do
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
- puts options.formatter.new.format(requires_list_average)
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
- requires << {name: name, time: Float(time) * 1000, rss: curr_rss - base_rss}
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,14 @@
1
+ module GemFootprintAnalyzer
2
+ module Formatters
3
+ class Json
4
+ require 'json'
5
+
6
+ def initialize(*)
7
+ end
8
+
9
+ def format(requires_list)
10
+ JSON.dump(requires_list)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -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
- if result
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
@@ -1,3 +1,3 @@
1
1
  module GemFootprintAnalyzer
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  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.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-20 00:00:00.000000000 Z
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/json_formatter.rb
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,8 +0,0 @@
1
- module GemFootprintAnalyzer
2
- class JsonFormatter
3
- require 'json'
4
- def format(requires_list)
5
- JSON.dump(requires_list)
6
- end
7
- end
8
- end
@@ -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