-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
tracerbench.js
77 lines (69 loc) · 1.88 KB
/
tracerbench.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const path = require('path');
const fs = require('fs-extra');
const { InitialRenderBenchmark, Runner } = require('@tracerbench/core');
// The number of samples TracerBench will run. Higher sample count is more accurate.
// However, the duration of the test will increase. The recommendation is somewhere between 30-60 samples.
const samplesCount = 60;
const markers = [
{
start: 'start-find-all',
label: 'start-find-all',
},
{
start: 'start-outer-materialization',
label: 'start-outer-materialization',
},
{
start: 'stop-outer-materialization',
label: 'stop-outer-materialization',
},
{
start: 'end-find-all',
label: 'end-find-all',
},
];
const browser = {
type: 'canary',
additionalArguments: [
'--headless',
'--disable-gpu',
'--hide-scrollbars',
'--mute-audio',
'--v8-cache-options=none',
'--disable-cache',
'--disable-v8-idle-tasks',
'--crash-dumps-dir=./tmp',
],
};
const TRACER_BENCH_RESULTS_PATH = path.resolve(
__dirname,
`../../../packages/unpublished-relationship-performance-test-app/tracerbench-results`
);
const control = new InitialRenderBenchmark({
name: 'control',
url: 'http://localhost:4200/?tracerbench=true',
markers,
browser,
saveTraces: () => path.resolve(TRACER_BENCH_RESULTS_PATH, 'control-trace.json'),
});
const experiment = new InitialRenderBenchmark({
name: 'experiment',
url: 'http://localhost:4201/?tracerbench=true',
markers,
browser,
saveTraces: () => path.resolve(TRACER_BENCH_RESULTS_PATH, 'experiment-trace.json'),
});
console.log('Computing results...');
const runner = new Runner([control, experiment]);
runner
.run(samplesCount)
.then(results => {
return fs.writeFileSync(
path.resolve(TRACER_BENCH_RESULTS_PATH, 'trace-results.json'),
JSON.stringify(results, null, 2)
);
})
.catch(err => {
console.error(err);
process.exit(1);
});