This repository has been archived by the owner on Sep 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
48 lines (38 loc) · 1.63 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var createPattern = function(path) {
return { pattern: path, included: true, served: true, watched: false };
};
var initBenchmark = function(files, config) {
files.unshift(createPattern(__dirname + '/lib/adapter.js'));
files.unshift(createPattern(__dirname + '/lib/benchmark.js'));
files.unshift(createPattern(require.resolve('lodash')));
};
initBenchmark.$inject = ['config.files'];
function BenchReporter(baseReporterDecorator) {
baseReporterDecorator(this);
this.onRunComplete = function(browsers, resultInfo) {
};
this.specSuccess = function(browser, result) {
var suite = result.benchmark.suite;
var name = result.benchmark.name;
this.write(suite + ' ' + name + ' at ' + Math.floor(result.benchmark.hz) + ' ops/sec ± ' + result.benchmark.stats.rme.toFixed(2) +'\n');
if (result.wasted) {
var that = this;
result.wasted.forEach(function (w) {
var component = w.key;
var inclusiveWasted = w.inclusiveRenderDuration;
var renderCount = w.renderCount;
var avgTime = inclusiveWasted / renderCount;
that.write('Wasted [' + component + '] renders: ' + renderCount +
', inclusive time: ' + inclusiveWasted.toFixed(4) + ' ms' +
', average time: ' + avgTime.toFixed(4) + ' ms' +
'\n');
});
this.write('\n');
}
};
}
BenchReporter.$inject = ['baseReporterDecorator'];
module.exports = {
'framework:react-perf': ['factory', initBenchmark],
'reporter:react-perf-reporter': ['type', BenchReporter]
};