Skip to content

Commit e1c17d9

Browse files
committed
feat(benchmark): improve sampling UI
* Increase default sample from 10 to 20 * Convert sample adjuster from range to input * Make sample list scrollable after 250px height
1 parent 387933d commit e1c17d9

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

benchmark/web/bp.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var bp = window.bp = {};
22
bp.steps = window.benchmarkSteps = [];
33
bp.runState = {
4-
numSamples: 10,
4+
numSamples: 20,
55
recentTimePerStep: {},
66
recentGCTimePerStep: {},
77
timesPerAction: {}
@@ -118,7 +118,11 @@ bp.runAllTests = function (done) {
118118

119119
bp.generateReportPartial = function(name, avg, fmtTimes, gcTimes) {
120120
return bp.interpolateHtml(
121-
'<tr><td>%0</td><td class="average">test:%1ms<br>gc:%2ms<br>combined: %3ms</td><td>%4</td><td>%5</td></tr>',
121+
'<tr class="sampleContainer">' +
122+
'<td>%0</td>' +
123+
'<td class="average">test:%1ms<br>gc:%2ms<br>combined: %3ms</td>' +
124+
'<td><div class="sampleContainer"><div class="testTimeCol">%4</div><div class="testTimeCol">%5</div></div></td>' +
125+
'</tr>',
122126
[
123127
name,
124128
('' + avg.time).substr(0,6),

benchmark/web/bp.spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('bp', function() {
2525
bp._container.appendChild(sampleRangeValue);
2626

2727
bp.runState = {
28-
numSamples: 10,
28+
numSamples: 20,
2929
recentTimePerStep: {},
3030
recentGCTimePerStep: {},
3131
timesPerAction: {}
@@ -189,9 +189,9 @@ describe('bp', function() {
189189

190190
describe('.addSampleRange()', function() {
191191
it('should set the default value to the current numSamples', function() {
192-
bp.runState.numSamples = 10;
192+
bp.runState.numSamples = 20;
193193
bp.addSampleRange();
194-
expect(bp.sampleRange.value).toBe('10');
194+
expect(bp.sampleRange.value).toBe('20');
195195
});
196196
});
197197

@@ -203,7 +203,7 @@ describe('bp', function() {
203203

204204

205205
it('should change the numSamples property', function() {
206-
expect(bp.runState.numSamples).toBe(10);
206+
expect(bp.runState.numSamples).toBe(20);
207207
bp.onSampleRangeChanged({target: {value: '80'}});
208208
expect(bp.runState.numSamples).toBe(80);
209209
});
@@ -241,9 +241,9 @@ describe('bp', function() {
241241

242242
describe('.setIterations()', function() {
243243
it('should set provided arguments to runState object', function() {
244-
bp.runState = {numSamples: 10};
244+
bp.runState = {numSamples: 20};
245245
bp.setIterations(15);
246-
expect(bp.runState.numSamples).toBe(10);
246+
expect(bp.runState.numSamples).toBe(20);
247247
expect(bp.runState.iterations).toBe(15);
248248
});
249249
});
@@ -429,7 +429,7 @@ describe('bp', function() {
429429
it('should return an html string with provided values', function() {
430430
bp.runState.numSamples = 9;
431431
expect(bp.generateReportPartial('foo', {time: 10, gcTime: 5}, ['9', '11'], ['4','6'])).
432-
toBe('<tr><td>foo</td><td class="average">test:10ms<br>gc:5ms<br>combined: 15ms</td><td>9<br>11</td><td>4<br>6</td></tr>')
432+
toBe('<tr class="sampleContainer"><td>foo</td><td class="average">test:10ms<br>gc:5ms<br>combined: 15ms</td><td><div class="sampleContainer"><div class="testTimeCol">9<br>11</div><div class="testTimeCol">4<br>6</div></div></td></tr>')
433433
});
434434
});
435435

benchmark/web/tree.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
<style>
1010
.bpLink { background: lightblue; padding: 1em; margin-bottom: 1.5em; }
1111
td.average { font-weight: bold; }
12+
.sampleContainer {max-height:250px; overflow-y: auto; }
13+
.testTimeCol { display: inline-block; width: 48%; }
1214
</style>
1315
</head>
1416

@@ -28,7 +30,7 @@
2830
Select number of samples to collect and average:
2931
<span id="sampleRangeValue"></span>
3032
</label>
31-
<input id="sampleRange" type="text">
33+
<input id="sampleRange" type="text" value="20">
3234
</div>
3335
</form>
3436
<div class="btn-group">
@@ -43,8 +45,14 @@
4345
<tr>
4446
<th>step</th>
4547
<th>average</th>
46-
<th>test time (ms)</th>
47-
<th>gc time (ms)</th>
48+
<th>
49+
<div class="testTimeCol">
50+
test time (ms)
51+
</div>
52+
<div class="testTimeCol" style="margin-left:-8px">
53+
gc time (ms)
54+
</div>
55+
</th>
4856
</tr>
4957
</thead>
5058
<tbody class="info" style="font-family: monospace"></tbody>

0 commit comments

Comments
 (0)