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 +4 -4
- data/lib/runtime_profiler.rb +4 -9
- data/lib/runtime_profiler/data.rb +11 -13
- data/lib/runtime_profiler/profiler.rb +16 -7
- data/lib/runtime_profiler/version.rb +1 -1
- data/runtime_profiler.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c65d8e5bf6fc5d9c3a429de889693927953c5194ae5a3562c76f2eed92f5ab09
|
4
|
+
data.tar.gz: 3067f05a450557a11c1a8c44d0573fae93fdef06b7daecde1b7c1ed1a6bfd6be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6712090d8b730c59d6250a12391962233b759dfeca38713b7cfe5bb6d714d6e99e38bef7b47262c30720b68f543b34e227d6e8cee73d1076fe68aba476755d3b
|
7
|
+
data.tar.gz: 454623783d6444cac238637b86f45e741479eeb1295f5ac246a003ac91a5b8f7b7be8a614fff1123f7c7c3e54bf077df8f5787173bcda1f7aac984fd74627ce8
|
data/lib/runtime_profiler.rb
CHANGED
@@ -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,
|
44
|
-
|
45
|
-
profiler = Profiler.new(
|
46
|
-
profiler.
|
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.
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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
|
-
|
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
|
-
|
24
|
+
subscribe_to_rails_event_notifications
|
17
25
|
prepare_methods_to_profile
|
18
26
|
end
|
19
27
|
|
20
|
-
def
|
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
|
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
|
42
|
-
|
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
|
-
|
55
|
+
unsubscribe_to_rails_event_notifications
|
47
56
|
|
48
57
|
profiling_data = RuntimeProfiler::Data.new \
|
49
58
|
controller_data: @action_controller_callback.controller_data,
|
data/runtime_profiler.gemspec
CHANGED
@@ -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.
|
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-
|
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:
|
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:
|
166
|
+
version: 0.4.3
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: terminal-table
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|