Skip to content

Commit e225d4c

Browse files
committed
Toggle the dashboard between Speed and Memory with radio buttons
Show one chart at a time on the top page, switched by Speed/Memory radio buttons like the ruby-bench page's Speedup/Time ones, and double the dashboard graph height to use the freed-up space.
1 parent 6f3410a commit e225d4c

2 files changed

Lines changed: 31 additions & 7 deletions

File tree

‎source/_dashboard.html.haml‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,17 @@
1212
%button.category_switch.activate-chart{ type: 'button', 'data-id': category.downcase, class: ('active' if index == 0) }= category
1313

1414
- %w[headline other micro].each do |category|
15-
.benchmark_graph{ id: category }
16-
.benchmark_graph.rss_graph{ id: "#{category}_rss" }
15+
.benchmark_graph.dashboard_graph{ id: category }
16+
.benchmark_graph.dashboard_graph.rss_graph{ id: "#{category}_rss" }
17+
18+
.text-center
19+
%div
20+
%label.form-check.form-check-inline.metric_type
21+
%input.form-check-input{ type: 'radio', name: 'metric_type', value: 'Speed', checked: true }
22+
Speed
23+
%label.form-check.form-check-inline.metric_type
24+
%input.form-check-input{ type: 'radio', name: 'metric_type', value: 'Memory' }
25+
Memory
1726

1827
:javascript
1928
$(function() {
@@ -112,13 +121,22 @@
112121
function activateChart(graphElement) {
113122
$('.benchmark_graph').hide();
114123
var category = graphElement.attr('id');
115-
var rssElement = $('#' + category + '_rss');
116-
graphElement.show();
117-
rssElement.show();
118-
plotSpeedChart(graphElement, category);
119-
plotRssChart(rssElement, category);
124+
if (RubyBench.getSelectedMetricType() === 'Memory') {
125+
var rssElement = $('#' + category + '_rss');
126+
rssElement.show();
127+
plotRssChart(rssElement, category);
128+
} else {
129+
graphElement.show();
130+
plotSpeedChart(graphElement, category);
131+
}
120132
}
121133

134+
// Re-render the active category when switching between Speed and Memory
135+
RubyBench.setupMetricTypeHandlers(function() {
136+
var id = $('.category_switch.active').data('id');
137+
activateChart($('#' + id));
138+
});
139+
122140
// Switch active tab and render it
123141
$('.activate-chart').on('click', function(event) {
124142
event.preventDefault();

‎source/stylesheets/site.css‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ a:hover {
4343
margin: 60px auto;
4444
}
4545

46+
/* The dashboard shows one graph at a time (Speed or Memory), so give it
47+
twice the height of the regular benchmark graphs */
48+
.benchmark_graph.dashboard_graph {
49+
height: 680px;
50+
}
51+
4652
/* Segmented control for switching benchmark categories, styled differently
4753
from the benchmark nav-pills below it */
4854
.category_switcher {

0 commit comments

Comments
 (0)