-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.js
134 lines (125 loc) · 2.86 KB
/
test.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import test from 'ava';
import teti from './';
test('should report DOM timings', async t => {
const connectStart = getConnectStart();
const domLoading = getDomLoading();
const domInteractive = getDomInteractive();
const domComplete = getDomComplete();
const firstPaint = getFirstPaint();
const fooBar = getFooBar();
const { results } = await teti({
number: 5,
url: '',
custom: ['foo bar'],
notify: () => {},
runner: () => Promise.resolve({
timing: {
connectStart: connectStart.next().value,
domLoading: domLoading.next().value,
domInteractive: domInteractive.next().value,
domComplete: domComplete.next().value
},
paint: [{
name: 'first-paint',
startTime: firstPaint.next().value
}],
mark: [{
name: 'foo bar',
entryType: 'mark',
startTime: fooBar.next().value,
duration: 0
}]
})
});
t.deepEqual(
results,
[{
name: 'domLoading',
metrics: {
mad: 0.06,
mean: 0.95,
median: 0.94,
p95: 1.1,
variance: 7.87
}
}, {
name: 'domInteractive',
metrics: {
mad: 0.12,
mean: 1.11,
median: 1.05,
p95: 1.36,
variance: 27.6
}
}, {
name: 'domComplete',
metrics: {
mad: 0.09,
mean: 1.38,
median: 1.35,
p95: 1.57,
variance: 13.75
}
}, {
name: 'first-paint',
metrics: {
mad: 0.02,
mean: 0.61,
median: 0.58,
p95: 0.68,
variance: 2.41
}
}, {
name: 'foo bar',
metrics: {
mad: 0.01,
mean: 2.13,
median: 2.16,
p95: 2.17,
variance: 4.56
}
}]
);
});
function* getDomLoading() {
yield 885;
yield 846;
yield 1000;
yield 1100;
yield 940;
}
function* getDomInteractive() {
yield 940;
yield 950;
yield 1360;
yield 1250;
yield 1060;
}
function* getDomComplete() {
yield 1350;
yield 1462;
yield 1570;
yield 1268;
yield 1271;
}
function* getConnectStart() {
yield 1;
yield 2;
yield 3;
yield 4;
yield 5;
}
function* getFirstPaint() {
yield 660;
yield 570;
yield 680;
yield 562;
yield 583;
}
function* getFooBar() {
yield 2160;
yield 2170;
yield 1993;
yield 2162;
yield 2153;
}