runtime_profiler 0.4.3 → 0.4.4

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: 10844b957c031772b37b68bfe5f2c83fc98c25c40c709eea8e6920badd400b04
4
- data.tar.gz: 52b61fe38de36b0f97fa16bbe742e3baa5e4444f22db6fa64e577deddeba491a
3
+ metadata.gz: c65d8e5bf6fc5d9c3a429de889693927953c5194ae5a3562c76f2eed92f5ab09
4
+ data.tar.gz: 3067f05a450557a11c1a8c44d0573fae93fdef06b7daecde1b7c1ed1a6bfd6be
5
5
  SHA512:
6
- metadata.gz: 289e5c785b16a2fb16ff17af9c1d7dbb02d765cf6990bac5ad1c7f4f6005042ff8589a80b79f54b7473705b5323adfb93b49cd31f4fa3e3934d9df15dbb31a6c
7
- data.tar.gz: 5b783916251fafdf991f7a3cca98336bc329ce96ff4b1efcb4f215dc2924439c3dabe797f66502956b4169bb72bc60512f3a7b7b04740463a65cb5c60a803353
6
+ metadata.gz: 6712090d8b730c59d6250a12391962233b759dfeca38713b7cfe5bb6d714d6e99e38bef7b47262c30720b68f543b34e227d6e8cee73d1076fe68aba476755d3b
7
+ data.tar.gz: 454623783d6444cac238637b86f45e741479eeb1295f5ac246a003ac91a5b8f7b7be8a614fff1123f7c7c3e54bf077df8f5787173bcda1f7aac984fd74627ce8
@@ -1,7 +1,6 @@
1
1
  require 'active_support'
2
2
 
3
3
  require 'runtime_profiler/profiler'
4
- require 'method_meter'
5
4
 
6
5
  module RuntimeProfiler
7
6
  include ActiveSupport::Configurable
@@ -40,14 +39,10 @@ module RuntimeProfiler
40
39
  yield self if block_given?
41
40
  end
42
41
 
43
- def profile!(key, konstants)
44
- konstants = konstants.is_a?(Array) ? konstants : [konstants]
45
- profiler = Profiler.new(konstants)
46
- profiler.prepare_for_profiling
47
-
48
- MethodMeter.measure!(key) { yield }
49
-
50
- profiler.save_profiling_data
42
+ def profile!(key, constants)
43
+ constants = constants.is_a?(Array) ? constants : [constants]
44
+ profiler = Profiler.new(constants)
45
+ profiler.profile!(key) { yield }
51
46
  end
52
47
  end
53
48
  end
@@ -61,19 +61,17 @@ module RuntimeProfiler
61
61
  profiled_methods = {}
62
62
 
63
63
  # TODO: Group methods under a key and under an object
64
- MethodMeter.measurement.each do |measurement|
65
- measurement.each_pair do |key, data|
66
- data.each do |d|
67
- object = d[:method].split(separator = '.')
68
- object = d[:method].split(separator = '#') if object.length == 1
69
-
70
- d[:method] = separator + object.second
71
-
72
- if profiled_methods[object.first]
73
- profiled_methods[object.first] << d
74
- else
75
- profiled_methods[object.first] = [d]
76
- end
64
+ MethodMeter.measurement.each_pair do |key, data|
65
+ data.each do |d|
66
+ object = d[:method].split(separator = '.')
67
+ object = d[:method].split(separator = '#') if object.length == 1
68
+
69
+ d[:method] = separator + object.second
70
+
71
+ if profiled_methods[object.first]
72
+ profiled_methods[object.first] << d
73
+ else
74
+ profiled_methods[object.first] = [d]
77
75
  end
78
76
  end
79
77
  end
@@ -1,4 +1,4 @@
1
- # require 'method_profiler'
1
+ require 'method_meter'
2
2
 
3
3
  require 'runtime_profiler/callbacks/active_record'
4
4
  require 'runtime_profiler/callbacks/action_controller'
@@ -10,14 +10,22 @@ module RuntimeProfiler
10
10
 
11
11
  def initialize(constants)
12
12
  self.profiled_constants = constants
13
+ prepare_for_profiling
13
14
  end
14
15
 
16
+ def profile!(key)
17
+ MethodMeter.measure!(key) { yield }
18
+ save_profiling_data
19
+ end
20
+
21
+ private
22
+
15
23
  def prepare_for_profiling
16
- subscribe_to_event_notifications
24
+ subscribe_to_rails_event_notifications
17
25
  prepare_methods_to_profile
18
26
  end
19
27
 
20
- def subscribe_to_event_notifications
28
+ def subscribe_to_rails_event_notifications
21
29
  @subscribers = []
22
30
 
23
31
  @active_record_callback = Callback::ActiveRecord.new
@@ -31,19 +39,20 @@ module RuntimeProfiler
31
39
  .subscribe('process_action.action_controller', @action_controller_callback)
32
40
  end
33
41
 
34
- def unsubscribe_to_event_notifications
42
+ def unsubscribe_to_rails_event_notifications
35
43
  @subscribers.each do |subscriber|
36
44
  ActiveSupport::Notifications.unsubscribe(subscriber)
37
45
  end
38
46
  end
39
47
 
40
48
  def prepare_methods_to_profile
41
- profiled_constants.flatten
42
- .each { |constant| MethodMeter.observe(constant, RuntimeProfiler.excepted_methods) }
49
+ profiled_constants
50
+ .flatten
51
+ .each { |constant| MethodMeter.observe(constant, RuntimeProfiler.excepted_methods) }
43
52
  end
44
53
 
45
54
  def save_profiling_data
46
- unsubscribe_to_event_notifications
55
+ unsubscribe_to_rails_event_notifications
47
56
 
48
57
  profiling_data = RuntimeProfiler::Data.new \
49
58
  controller_data: @action_controller_callback.controller_data,
@@ -1,3 +1,3 @@
1
1
  module RuntimeProfiler
2
- VERSION = '0.4.3'.freeze
2
+ VERSION = '0.4.4'.freeze
3
3
  end
@@ -28,6 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.add_runtime_dependency 'commander'
29
29
  spec.add_runtime_dependency 'defined_methods'
30
30
  spec.add_runtime_dependency 'hirb'
31
- spec.add_runtime_dependency 'method_meter'
31
+ spec.add_runtime_dependency 'method_meter', '>= 0.4.3'
32
32
  spec.add_runtime_dependency 'terminal-table'
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runtime_profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wilfrido T. Nuqui Jr.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-02 00:00:00.000000000 Z
11
+ date: 2021-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: '0'
159
+ version: 0.4.3
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
- version: '0'
166
+ version: 0.4.3
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: terminal-table
169
169
  requirement: !ruby/object:Gem::Requirement