Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit da67e23

Browse files
jeffbcrossjbdeboer
authored andcommitted
chore(benchmark): remove redundant getAverages method
1 parent 553be2e commit da67e23

File tree

2 files changed

+12
-37
lines changed

2 files changed

+12
-37
lines changed

benchmark/web/bp.js

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ bp.Statistics.getMean = function (sample) {
1717
var total = 0;
1818
sample.forEach(function(x) { total += x; });
1919
return total / sample.length;
20-
}
20+
};
2121

2222
bp.Statistics.calculateConfidenceInterval = function(standardDeviation, sampleSize) {
2323
var standardError = standardDeviation / Math.sqrt(sampleSize);
@@ -143,6 +143,7 @@ bp.runTimedTest = function (bs) {
143143
};
144144

145145
bp.runAllTests = function (done) {
146+
var report;
146147
if (bp.runState.iterations--) {
147148
bp.steps.forEach(function(bs) {
148149
var testResults = bp.runTimedTest(bs);
@@ -151,14 +152,14 @@ bp.runAllTests = function (done) {
151152
bp.runState.recentGarbagePerStep[bs.name] = testResults.garbage;
152153
bp.runState.recentRetainedMemoryPerStep[bs.name] = testResults.retainedDelta;
153154
});
154-
bp.report = bp.calcStats();
155-
bp.writeReport(bp.report);
155+
report = bp.calcStats();
156+
bp.writeReport(report);
156157
window.requestAnimationFrame(function() {
157158
bp.runAllTests(done);
158159
});
159160
}
160161
else {
161-
bp.writeReport(bp.report);
162+
bp.writeReport(report);
162163
bp.resetIterations();
163164
done && done();
164165
}
@@ -184,15 +185,6 @@ bp.generateReportPartial = function(model) {
184185
return bp.infoTemplate(model);
185186
};
186187

187-
bp.getAverages = function (times, gcTimes, garbageTimes, retainedTimes) {
188-
return {
189-
gcTime: bp.Statistics.getMean(gcTimes),
190-
time: bp.Statistics.getMean(times),
191-
garbage: bp.Statistics.getMean(garbageTimes),
192-
retained: bp.Statistics.getMean(retainedTimes)
193-
};
194-
};
195-
196188
bp.writeReport = function(reportContent) {
197189
bp.infoDiv.innerHTML = reportContent;
198190
};
@@ -254,11 +246,13 @@ bp.calcStats = function() {
254246

255247
tpa.nextEntry++;
256248
tpa.nextEntry %= bp.runState.numSamples;
257-
avg = bp.getAverages(
258-
tpa.times,
259-
tpa.gcTimes,
260-
tpa.garbageTimes,
261-
tpa.retainedTimes);
249+
avg = {
250+
gcTime: bp.Statistics.getMean(tpa.gcTimes),
251+
time: bp.Statistics.getMean(tpa.times),
252+
garbage: bp.Statistics.getMean(tpa.garbageTimes),
253+
retained: bp.Statistics.getMean(tpa.retainedTimes)
254+
};
255+
262256
timesStandardDeviation = bp.Statistics.calculateStandardDeviation(tpa.times, avg.time);
263257
timesConfidenceInterval = bp.Statistics.calculateConfidenceInterval(
264258
timesStandardDeviation,

benchmark/web/bp.spec.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -381,18 +381,6 @@ describe('bp', function() {
381381
});
382382

383383

384-
describe('.getAverages()', function() {
385-
it('should return the average of a set of numbers', function() {
386-
expect(bp.getAverages([100,0,50,75,25], [2,4,2,4,3], [1,2],[3,4])).toEqual({
387-
gcTime: 3,
388-
time: 50,
389-
garbage: 1.5,
390-
retained: 3.5
391-
});
392-
});
393-
});
394-
395-
396384
describe('.calcStats()', function() {
397385
beforeEach(function() {
398386
bp.steps = [mockStep];
@@ -435,13 +423,6 @@ describe('bp', function() {
435423
});
436424

437425

438-
it('should call getAverages() with the correct info', function() {
439-
var spy = spyOn(bp, 'getAverages').andCallThrough();
440-
bp.calcStats();
441-
expect(spy).toHaveBeenCalledWith([ 3, 7, 5 ], [ 1, 3, 2 ], [50,50,0.2], [25,25,0.1]);
442-
});
443-
444-
445426
it('should set the most recent time for each step to the next entry', function() {
446427
bp.calcStats();
447428
expect(bp.runState.timesPerAction.fakeStep.times[2]).toBe(5);

0 commit comments

Comments
 (0)