rails_performance 0.0.1.1 → 0.0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/rails_performance_controller.rb +1 -1
- data/app/helpers/rails_performance_helper.rb +8 -0
- data/app/views/rails_performance/_css.html.erb +1 -1
- data/app/views/rails_performance/index.html.erb +18 -5
- data/lib/rails_performance/base_report.rb +8 -2
- data/lib/rails_performance/engine.rb +6 -0
- data/lib/rails_performance/metrics_listener.rb +2 -0
- data/lib/rails_performance/requests_report.rb +17 -5
- data/lib/rails_performance/throughput_report.rb +2 -2
- data/lib/rails_performance/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68f35c4eec4521b60ad740040da1a980e517f951444f52563dedf1f9e5958c8a
|
4
|
+
data.tar.gz: 0b384d8bda35a86b7fbc384b2834829eb2f8bd92edf01d974bd75d139748f749
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad282e2024c5eadf23eade5c6b02dc31255f8bd1fe34b9b03c2557f5a5d2a1ab640f9b23d13d2e2c0dbf081b6fd4cec2b6ac34bacf6e722e81b8c2de69b5c321
|
7
|
+
data.tar.gz: 3ef27d25873473bfd87369356ecbd28d57471ce27240513f01d0a546c80ab8790c983b0ad9e9ecc61bddfe0b9c9a64dad8dd274981890dd2e34e69b697724664
|
@@ -8,7 +8,7 @@ class RailsPerformanceController < ActionController::Base
|
|
8
8
|
})
|
9
9
|
|
10
10
|
@data = RailsPerformance::ThroughputReport.new(@datasource.db).data
|
11
|
-
@global = RailsPerformance::RequestsReport.new(@datasource.db, group: :controller_action_format).data
|
11
|
+
@global = RailsPerformance::RequestsReport.new(@datasource.db, group: :controller_action_format, sort: :db_runtime_slowest).data
|
12
12
|
#@full = RailsPerformance::FullReport.new.data(:controller_action).sort{|a, b| b[:count] <=> a[:count]}
|
13
13
|
end
|
14
14
|
|
@@ -21,11 +21,20 @@
|
|
21
21
|
<table>
|
22
22
|
<thead>
|
23
23
|
<tr>
|
24
|
-
<th
|
24
|
+
<th colspan='3'>Name</th>
|
25
|
+
<th colspan='3'>Average (ms)</th>
|
26
|
+
<th colspan='3'>Slowest (ms)</th>
|
27
|
+
</tr>
|
28
|
+
<tr>
|
29
|
+
<th>Controller#Action</th>
|
25
30
|
<th>Format</th>
|
26
31
|
<th>Requests</th>
|
27
|
-
<th>
|
28
|
-
<th>
|
32
|
+
<th>Duration</th>
|
33
|
+
<th>Views</th>
|
34
|
+
<th>DB</th>
|
35
|
+
<th>Duration</th>
|
36
|
+
<th>Views</th>
|
37
|
+
<th>DB</th>
|
29
38
|
</tr>
|
30
39
|
</thead>
|
31
40
|
<tbody>
|
@@ -35,8 +44,12 @@
|
|
35
44
|
<td><%= groups[0] %></td>
|
36
45
|
<td><%= groups[1]&.upcase %></td>
|
37
46
|
<td><%= e[:count] %></td>
|
38
|
-
<td><%= e[:
|
39
|
-
<td><%= e[:
|
47
|
+
<td><%= round_it e[:duration_average] %></td>
|
48
|
+
<td><%= round_it e[:view_runtime_average] %></td>
|
49
|
+
<td><%= round_it e[:db_runtime_average] %></td>
|
50
|
+
<td><%= round_it e[:duration_slowest] %></td>
|
51
|
+
<td><%= round_it e[:view_runtime_slowest] %></td>
|
52
|
+
<td><%= round_it e[:db_runtime_slowest] %></td>
|
40
53
|
</tr>
|
41
54
|
<% end %>
|
42
55
|
</tbody>
|
@@ -1,10 +1,13 @@
|
|
1
1
|
module RailsPerformance
|
2
2
|
class BaseReport
|
3
|
-
attr_reader :db, :group
|
3
|
+
attr_reader :db, :group, :sort
|
4
4
|
|
5
|
-
def initialize(db, group: nil)
|
5
|
+
def initialize(db, group: nil, sort: nil)
|
6
6
|
@db = db
|
7
7
|
@group = group
|
8
|
+
@sort = sort
|
9
|
+
|
10
|
+
set_defaults
|
8
11
|
end
|
9
12
|
|
10
13
|
def collect
|
@@ -13,5 +16,8 @@ module RailsPerformance
|
|
13
16
|
res
|
14
17
|
end
|
15
18
|
end
|
19
|
+
|
20
|
+
def set_defaults
|
21
|
+
end
|
16
22
|
end
|
17
23
|
end
|
@@ -19,6 +19,8 @@ module RailsPerformance
|
|
19
19
|
def call(event_name, started, finished, event_id, payload)
|
20
20
|
event = ActiveSupport::Notifications::Event.new(event_name, started, finished, event_id, payload)
|
21
21
|
|
22
|
+
#finished = Time.now - rand(180).minutes
|
23
|
+
|
22
24
|
record = {
|
23
25
|
controller: event.payload[:controller],
|
24
26
|
action: event.payload[:action],
|
@@ -1,14 +1,26 @@
|
|
1
1
|
module RailsPerformance
|
2
2
|
class RequestsReport < BaseReport
|
3
|
+
def set_defaults
|
4
|
+
@sort ||= :count
|
5
|
+
end
|
6
|
+
|
3
7
|
def data
|
4
8
|
collect do |k, v|
|
9
|
+
durations = v.collect{|e| e["duration"]}.compact
|
10
|
+
view_runtimes = v.collect{|e| e["view_runtime"]}.compact
|
11
|
+
db_runtimes = v.collect{|e| e["db_runtime"]}.compact
|
12
|
+
|
5
13
|
{
|
6
|
-
group:
|
7
|
-
|
8
|
-
|
9
|
-
|
14
|
+
group: k,
|
15
|
+
count: v.size,
|
16
|
+
duration_average: durations.sum.to_f / durations.size,
|
17
|
+
view_runtime_average: view_runtimes.sum.to_f / view_runtimes.size,
|
18
|
+
db_runtime_average: db_runtimes.sum.to_f / db_runtimes.size,
|
19
|
+
duration_slowest: durations.max,
|
20
|
+
view_runtime_slowest: view_runtimes.max,
|
21
|
+
db_runtime_slowest: db_runtimes.max,
|
10
22
|
}
|
11
|
-
end.sort{|a, b| b[
|
23
|
+
end.sort{|a, b| b[sort] <=> a[sort]}
|
12
24
|
end
|
13
25
|
end
|
14
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_performance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- Rakefile
|
93
93
|
- app/assets/config/rails_performance_manifest.js
|
94
94
|
- app/controllers/rails_performance_controller.rb
|
95
|
+
- app/helpers/rails_performance_helper.rb
|
95
96
|
- app/views/rails_performance/_css.html.erb
|
96
97
|
- app/views/rails_performance/_js.html.erb
|
97
98
|
- app/views/rails_performance/index.html.erb
|