rails_performance 0.0.1.4 → 0.0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 457bfaa0d79609d19c413eba29dd8d859bdd44914f1b89575479670e93f7cd4c
4
- data.tar.gz: 5ba7326c5428c8619c7f8d00762e2e4c93f94706fa62c05d6568c4888b22400f
3
+ metadata.gz: 6810e07a3e81d629d2ea4933dc54167ee92914077ea0d6171e2e5c5daa6112cd
4
+ data.tar.gz: ae07b67293815fbe1456dafe09212f9598e3da7714989c8eb7d7b583e0d6fa78
5
5
  SHA512:
6
- metadata.gz: b0092789df6c6f941c5625bdeab09e3428a18454eb146d5bb2e861939b117288be7f3fae207bc73acf6b2e357cd40d15fbff507a3270ef3c7eb96739c84152bf
7
- data.tar.gz: e40e5f82fbd08e70fe0d279824b3ecb75dbc0e303e27a9dd53be38b7b9519aef7c08565e76d2a4640c32f586a3aa6d6d673ec9b26d5c8342cdf0b371bc56923d
6
+ metadata.gz: 797fa181f1b6dddcf94b5dce0cd8ce3c238fa6ec003b37f74ca540aa57896eea0ed0bb60dd121a0c112e2d966d4d8b637b04bdf29e3a459b1e1a957cca317bb5
7
+ data.tar.gz: effa86b38a58301915bed0b0a93fb09bc354eb0ffd40d15e63aff61f7222bf758f5d7b3b5767bad5ffd8d5d1f4650f96d905d591c6392eb783ce821d5ab88442
@@ -1,26 +1,25 @@
1
1
  class RailsPerformanceController < ActionController::Base
2
2
 
3
3
  def index
4
- @datasource = RailsPerformance::DataSource.new(RailsPerformance::QueryBuilder.compose_from(params))
4
+ @datasource = RP::DataSource.new(RP::QueryBuilder.compose_from(params))
5
+ db = @datasource.db
5
6
 
6
- @throughput_report = RailsPerformance::Reports::ThroughputReport.new(@datasource.db)
7
+ @throughput_report = RP::Reports::ThroughputReport.new(db)
7
8
  @throughput_report_data = @throughput_report.data
8
9
 
9
- @response_time_report = RailsPerformance::Reports::ResponseTimeReport.new(@datasource.db)
10
+ @response_time_report = RP::Reports::ResponseTimeReport.new(db)
10
11
  @response_time_report_data = @response_time_report.data
11
12
 
12
- @global_report = RailsPerformance::Reports::RequestsReport.new(@datasource.db, group: :controller_action_format, sort: :db_runtime_slowest)
13
+ @global_report = RP::Reports::RequestsReport.new(db, group: :controller_action_format, sort: :db_runtime_slowest)
13
14
  @global_report_data = @global_report.data
14
15
  end
15
16
 
16
- # def RailsPerformanceController.x
17
- # @datasource = RailsPerformance::DataSource.new(
18
- # q: {
19
- # controller: "HomeController",
20
- # action: "about"
21
- # })
17
+ def breakdown
18
+ @datasource = RP::DataSource.new(RP::QueryBuilder.compose_from(params))
19
+ db = @datasource.db
22
20
 
23
- # @data = RailsPerformance::ThroughputReport2.new(@datasource).data
24
- # end
21
+ @breakdown_report = RP::Reports::BreakdownReport.new(db, title: "Breakdown Report: #{@datasource.q.to_param}")
22
+ @breakdown_report_data = @breakdown_report.data
23
+ end
25
24
 
26
25
  end
@@ -22,4 +22,16 @@ module RailsPerformanceHelper
22
22
 
23
23
  link_to title, rails_performance_path(options), target: '_blank'
24
24
  end
25
+
26
+ def stats_icon
27
+ '<?xml version="1.0" ?><svg height="48" id="graph-bar" viewBox="0 0 48 48" width="48" xmlns="http://www.w3.org/2000/svg"><defs><style> .vi-primary { fill: #FF6E6E; } .vi-primary, .vi-accent { stroke: #fff; stroke-linecap: round; stroke-width: 0; } .vi-accent { fill: #0C0058; } </style></defs><rect class="vi-accent" height="4" width="36" x="6" y="35"/><path class="vi-primary" d="M9,20h5V35H9V20Zm8,5h5V35H17V25Zm8-9h5V35H25V16Zm8-7h5V35H33V9Z"/></svg>'
28
+ end
29
+
30
+ def insert_css_file(file)
31
+ raw "<style>#{raw File.read File.expand_path(File.dirname(__FILE__) + "/../views/stylesheets/#{file}")}</style>"
32
+ end
33
+
34
+ def insert_js_file(file)
35
+ raw "<script>#{raw File.read File.expand_path(File.dirname(__FILE__) + "/../views/javascripts/#{file}")}</script>"
36
+ end
25
37
  end
@@ -0,0 +1,7 @@
1
+ <%= javascript_include_tag 'https://code.highcharts.com/highcharts.js' %>
2
+ <%= javascript_include_tag 'https://code.highcharts.com/modules/data.js' %>
3
+ <%= javascript_include_tag 'https://code.highcharts.com/modules/exporting.js' %>
4
+ <%= javascript_include_tag 'https://code.highcharts.com/modules/export-data.js' %>
5
+ <%= javascript_include_tag 'https://code.highcharts.com/modules/accessibility.js' %>
6
+
7
+ <%= insert_js_file 'app.js' %>
@@ -0,0 +1,148 @@
1
+ function showTIRChart(div, data) {
2
+ Highcharts.chart(div, {
3
+ time: {
4
+ timezone: 'Europe/Kiev'
5
+ },
6
+ chart: {
7
+ type: 'area',
8
+ zoomType: 'x',
9
+ },
10
+ title: {
11
+ text: ''
12
+ },
13
+ xAxis: {
14
+ crosshair: true,
15
+ type: 'datetime',
16
+ labels: {
17
+ style: {
18
+ color: "#a6b0cf"
19
+ }
20
+ }
21
+ },
22
+ yAxis: {
23
+ min: 0,
24
+ title: {
25
+ text: 'RPM',
26
+ style: {
27
+ color: "#f6f6f6"
28
+ }
29
+ },
30
+ labels: {
31
+ style: {
32
+ color: "#a6b0cf"
33
+ }
34
+ }
35
+ },
36
+ legend: {
37
+ enabled: false
38
+ },
39
+ exporting: {
40
+ buttons: {
41
+ contextButton: {
42
+ theme: {
43
+ fill: "#eee"
44
+ }
45
+ }
46
+ }
47
+ },
48
+ plotOptions: {
49
+ area: {
50
+ color: '#ff5b5b',
51
+ }
52
+ },
53
+ series: [{
54
+ type: 'area',
55
+ name: 'Requests per minute',
56
+ data: data,
57
+ fillOpacity: 0.3,
58
+ lineWidth: 1
59
+ }]
60
+ });
61
+ };
62
+
63
+ function showRTChart(div, data) {
64
+ Highcharts.chart(div, {
65
+ time: {
66
+ timezone: 'Europe/Kiev'
67
+ },
68
+ chart: {
69
+ type: 'area',
70
+ zoomType: 'x',
71
+ },
72
+ title: {
73
+ text: ''
74
+ },
75
+
76
+ tooltip: {
77
+ // positioner: function () {
78
+ // return {
79
+ // // right aligned
80
+ // x: this.chart.chartWidth - this.label.width - 30,
81
+ // y: 5 // align to title
82
+ // };
83
+ // },
84
+ borderWidth: 0,
85
+ backgroundColor: 'none',
86
+ pointFormat: '{point.y}',
87
+ //headerFormat: '',
88
+ shadow: false,
89
+ style: {
90
+ fontSize: '16px',
91
+ color: '#000',
92
+ },
93
+ formatter: function() {
94
+ if (this.y == 0) {
95
+ return "";
96
+ }
97
+ return this.y + ' ms';
98
+ }
99
+ },
100
+ xAxis: {
101
+ crosshair: false,
102
+ type: 'datetime',
103
+ labels: {
104
+ style: {
105
+ color: "#a6b0cf"
106
+ }
107
+ }
108
+ },
109
+ yAxis: {
110
+ min: 0,
111
+ title: {
112
+ text: 'Time',
113
+ style: {
114
+ color: "#f6f6f6"
115
+ }
116
+ },
117
+ labels: {
118
+ style: {
119
+ color: "#a6b0cf"
120
+ }
121
+ }
122
+ },
123
+ legend: {
124
+ enabled: false
125
+ },
126
+ exporting: {
127
+ buttons: {
128
+ contextButton: {
129
+ theme: {
130
+ fill: "#eee"
131
+ }
132
+ }
133
+ }
134
+ },
135
+ plotOptions: {
136
+ area: {
137
+ color: '#ff5b5b',
138
+ }
139
+ },
140
+ series: [{
141
+ type: 'area',
142
+ name: 'Response Time',
143
+ data: data,
144
+ fillOpacity: 0.3,
145
+ lineWidth: 1
146
+ }]
147
+ });
148
+ };
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Hello Bulma!</title>
7
+ <%= render '/stylesheets/stylesheets' %>
8
+ </head>
9
+ <body>
10
+ <section class="section">
11
+ <div class="container is-fluid">
12
+ <%= yield %>
13
+ </div>
14
+ </section>
15
+ <%= render '/javascripts/javascripts' %>
16
+ <%= yield :on_load %>
17
+ </body>
18
+ </html>
@@ -0,0 +1,35 @@
1
+ <title><%= @breakdown_report.title %></title>
2
+
3
+ <div class="card">
4
+ <div class="card-content">
5
+ <h1 class="title"><%= @breakdown_report.title %><h1>
6
+ <table class="table is-fullwidth">
7
+ <thead>
8
+ <tr>
9
+ <th>Controller # Action</th>
10
+ <th>Path</th>
11
+ <th>Method</th>
12
+ <th>Format</th>
13
+ <th>Duration</th>
14
+ <th>Views</th>
15
+ <th>DB</th>
16
+ <th>Datetime</th>
17
+ </tr>
18
+ </thead>
19
+ <tbody>
20
+ <% @breakdown_report_data.each do |e| %>
21
+ <tr>
22
+ <td><%= e[:controller] + '#' + e[:action] %></td>
23
+ <td><%= e[:path] %></td>
24
+ <td><%= e[:method] %></td>
25
+ <td><%= e[:format] %></td>
26
+ <td><%= round_it e[:duration] %></td>
27
+ <td><%= round_it e[:view_runtime] %></td>
28
+ <td><%= round_it e[:db_runtime] %></td>
29
+ <td><%= l e[:datetime], format: :short %></td>
30
+ </tr>
31
+ <% end %>
32
+ </tbody>
33
+ </table>
34
+ </div>
35
+ </div>
@@ -1,87 +1,79 @@
1
- <%= render '/rails_performance/css' %>
2
-
3
1
  <title>Number of Requests to the Application</title>
4
2
 
5
3
  <% unless @datasource.default? %>
6
- <%= link_to raw("&larr; Back"), rails_performance_path, class: "back_link" %>
4
+ <%#= link_to raw("&larr; Back"), rails_performance_path, class: "back_link" %>
7
5
  <% end %>
8
6
 
9
- <br/>
10
- <br/>
11
- <br/>
12
-
13
7
  <div class="card">
14
- <h1>Throughput Report<h1>
15
- <div id="throughput_report_chart"></div>
16
- <p class="hint">All requests (site visitors, search engines, bots, etc)</p>
8
+ <div class="card-content">
9
+ <h2 class="title">Throughput Report<h1>
10
+ <div id="throughput_report_chart" class="chart"></div>
11
+ <p class="content is-small">All requests (site visitors, search engines, bots, etc)</p>
12
+ </div>
17
13
  </div>
18
14
 
19
- <br/>
20
- <br/>
21
- <br/>
22
-
23
15
  <div class="card">
24
- <h1>Average Response Time Report<h1>
25
- <div id="response_time_report_chart"></div>
26
- <p class="hint">All requests (site visitors, search engines, bots, etc)</p>
16
+ <div class="card-content">
17
+ <h2 class="title">Average Response Time Report<h1>
18
+ <div id="response_time_report_chart" class="chart"></div>
19
+ <p class="content is-small">All requests (site visitors, search engines, bots, etc)</p>
20
+ </div>
27
21
  </div>
28
22
 
29
- <br/>
30
- <br/>
31
- <br/>
32
-
33
23
  <div class="card">
34
- <h1>Requests (path, total number, average response time)<h1>
35
- <table>
36
- <thead>
37
- <tr>
38
- <th colspan='3'>Name</th>
39
- <th colspan='3'>Average (ms)</th>
40
- <th colspan='3'>Slowest (ms)</th>
41
- </tr>
42
- <tr>
43
- <th>Controller#Action</th>
44
- <th>Format</th>
45
- <th>Requests</th>
46
- <th>Duration</th>
47
- <th>Views</th>
48
- <th>DB</th>
49
- <th>Duration</th>
50
- <th>Views</th>
51
- <th>DB</th>
52
- </tr>
53
- </thead>
54
- <tbody>
55
- <% @global_report_data.each do |e| %>
56
- <% groups = e[:group].split("|") %>
24
+ <div class="card-content">
25
+ <h2 class="title">Requests (path, total number, average response time)<h1>
26
+ <table class="table is-fullwidth">
27
+ <thead>
28
+ <tr>
29
+ <th colspan='3'>Name</th>
30
+ <th colspan='3'>Average (ms)</th>
31
+ <th colspan='3'>Slowest (ms)</th>
32
+ </tr>
57
33
  <tr>
58
- <td><%= statistics_link groups[0], @global_report, e[:group] %></td>
59
- <td><%= groups[1]&.upcase %></td>
60
- <td><%= e[:count] %></td>
61
- <td><%= round_it e[:duration_average] %></td>
62
- <td><%= round_it e[:view_runtime_average] %></td>
63
- <td><%= round_it e[:db_runtime_average] %></td>
64
- <td><%= round_it e[:duration_slowest] %></td>
65
- <td><%= round_it e[:view_runtime_slowest] %></td>
66
- <td><%= round_it e[:db_runtime_slowest] %></td>
34
+ <th>Controller#Action</th>
35
+ <th>Format</th>
36
+ <th>Requests</th>
37
+ <th>Duration</th>
38
+ <th>Views</th>
39
+ <th>DB</th>
40
+ <th>Duration</th>
41
+ <th>Views</th>
42
+ <th>DB</th>
67
43
  </tr>
68
- <% end %>
69
- </tbody>
70
- </table>
44
+ </thead>
45
+ <tbody>
46
+ <% @global_report_data.each do |e| %>
47
+ <% groups = e[:group].split("|") %>
48
+ <% c, a = groups[0].split("#") %>
49
+ <tr>
50
+ <td>
51
+ <%= statistics_link groups[0], @global_report, e[:group] %>
52
+ <%= link_to rails_performance.rails_performance_breakdown_path(controller_eq: c, action_eq: a), class: 'stats_icon', target: '_blank' do %>
53
+ <%= raw(stats_icon) %>
54
+ <% end %>
55
+ </td>
56
+ <td><%= groups[1]&.upcase %></td>
57
+ <td><%= e[:count] %></td>
58
+ <td><%= round_it e[:duration_average] %></td>
59
+ <td><%= round_it e[:view_runtime_average] %></td>
60
+ <td><%= round_it e[:db_runtime_average] %></td>
61
+ <td><%= round_it e[:duration_slowest] %></td>
62
+ <td><%= round_it e[:view_runtime_slowest] %></td>
63
+ <td><%= round_it e[:db_runtime_slowest] %></td>
64
+ </tr>
65
+ <% end %>
66
+ </tbody>
67
+ </table>
68
+ </div>
71
69
  </div>
72
70
 
73
- <br/>
74
- <br/>
75
- <br/>
76
-
77
-
78
- <%= render '/rails_performance/js' %>
79
-
80
- <script>
81
- var data1 = <%= raw @throughput_report_data.to_json %>;
82
- showTIRChart('throughput_report_chart', data1);
83
-
84
- var data2 = <%= raw @response_time_report_data.to_json %>;
85
- showRTChart('response_time_report_chart', data2);
86
- </script>
71
+ <% content_for :on_load do %>
72
+ <script>
73
+ var data1 = <%= raw @throughput_report_data.to_json %>;
74
+ showTIRChart('throughput_report_chart', data1);
87
75
 
76
+ var data2 = <%= raw @response_time_report_data.to_json %>;
77
+ showRTChart('response_time_report_chart', data2);
78
+ </script>
79
+ <% end %>
@@ -0,0 +1,2 @@
1
+ <%= insert_css_file "bulma.min.css" %>
2
+ <%= insert_css_file "style.css" %>