3
3
/* TIMING */
4
4
5
5
function check_timing ( type ) {
6
+ if ( 'perf_timing' == type ) { return true }
7
+
6
8
let setTiming = new Set ( ) , value , result = true
9
+ let aIgnore = [ 0 , 1 , 16 , 17 ]
7
10
let max = isPerf ? 10 : 500
8
11
for ( let i = 1 ; i < max ; i ++ ) {
9
12
try {
@@ -17,9 +20,9 @@ function check_timing(type) {
17
20
} else if ( 'currenttime' == type ) {
18
21
value = ( gTimeline . currentTime ) - ( gTimeline . currentTime )
19
22
}
20
- value = Math . trunc ( value )
23
+ value = Math . abs ( Math . trunc ( value ) )
21
24
// should match or the clock ticks over, e.g. 1ms or 16/17ms
22
- if ( 0 !== value && - 1 !== value && - 16 !== value ) { result = false }
25
+ if ( ! aIgnore . includes ( value ) ) { result = false }
23
26
setTiming . add ( value )
24
27
} catch ( e ) {
25
28
// we would have already captured errors
@@ -44,7 +47,6 @@ function get_timing(METRIC) {
44
47
} catch ( e ) { }
45
48
try { gData . timing [ 'date' ] . push ( ( new Date ( ) ) [ Symbol . toPrimitive ] ( 'number' ) ) } catch ( e ) { }
46
49
try { gData . timing [ 'currenttime' ] . push ( gTimeline . currentTime ) } catch ( e ) { }
47
-
48
50
/* testing
49
51
gData.timing.date = [1723240561321]
50
52
gData.timing.exslt = ['2024-08-09T20:23:10.000','2024-08-09T20:23:11.000']
@@ -53,8 +55,30 @@ function get_timing(METRIC) {
53
55
gData.timing.currenttime = [257788.489, 258121.829, 258438.502, 259021.847]
54
56
//*/
55
57
58
+ let aList = [ 'connectStart' , 'domComplete' , 'domContentLoadedEventEnd' , 'domContentLoadedEventStart' , 'domInteractive' , 'domLoading' ,
59
+ 'domainLookupEnd' , 'domainLookupStart' , 'fetchStart' , 'loadEventEnd' , 'loadEventStart' , 'navigationStart' , 'redirectEnd' , 'redirectStart' ,
60
+ 'requestStart' , 'responseEnd' , 'responseStart' , 'secureConnectionStart' , 'unloadEventEnd' , 'unloadEventStart' , ]
61
+ let tmpTiming = [ ]
62
+ try {
63
+ let tmpobj = performance . timing
64
+ if ( 0 === ( tmpobj . loadEventEnd - tmpobj . navigationStart ) ) {
65
+ throw zD
66
+ } else {
67
+ aList . forEach ( function ( k ) {
68
+ let value = performance . timing [ k ]
69
+ if ( undefined !== value && 0 !== value ) { tmpTiming . push ( value ) }
70
+ } )
71
+ tmpTiming = tmpTiming . filter ( function ( item , position ) { return tmpTiming . indexOf ( item ) === position } )
72
+ tmpTiming = tmpTiming . sort ( function ( a , b ) { return a - b } )
73
+ gData . timing [ 'perf_timing' ] = tmpTiming
74
+ }
75
+ } catch ( e ) {
76
+ gData . timing [ 'perf_timing' ] = e + ''
77
+ }
78
+
56
79
let oGood = {
57
80
'date' : [ 0 , 1 , 16 , 17 , 33 , 34 ] ,
81
+ 'perf_timing' : [ 0 , 1 , 16 , 17 , 33 , 34 ] ,
58
82
'currenttime' : [
59
83
0 , 0.01 , 0.02 , 0.03 , 0.04 ,
60
84
16.66 , 16.67 , 16.68 , 16.69 , 16.7 ,
@@ -184,9 +208,9 @@ function get_timing(METRIC) {
184
208
data = aDiffs
185
209
//console.log(k, data, isZero, is10, is100, aDiffs, aTotal)
186
210
} catch ( e ) {
187
- str = log_error ( 17 , METRIC + '_' + k , e )
211
+ str = zD == e ? zD : log_error ( 17 , METRIC + '_' + k , e )
188
212
data = str
189
- oData [ k ] = zErr
213
+ oData [ k ] = zD == str ? zD : zErr
190
214
countFail ++
191
215
}
192
216
//sDetail.document[METRIC][k] = data
@@ -203,20 +227,6 @@ function get_timing(METRIC) {
203
227
return
204
228
}
205
229
206
- function get_perf_timing ( METRIC ) {
207
- // dom.enable_performance
208
- let str , data = ''
209
- try {
210
- if ( runSE ) { foo ++ }
211
- let timing = performance . timing
212
- str = ( timing . loadEventEnd - timing . navigationStart ) == 0 ? zD : zE
213
- } catch ( e ) {
214
- str = e ; data = zErrLog
215
- }
216
- addBoth ( 17 , METRIC , str , '' , '' , data )
217
- return
218
- }
219
-
220
230
function get_perf_resource ( METRIC ) {
221
231
// dom.enable_resource_timing
222
232
let str , data = ''
@@ -576,7 +586,6 @@ const outputTiming = () => new Promise(resolve => {
576
586
Promise . all ( [
577
587
get_timing ( 'timing_precision' ) ,
578
588
get_perf_resource ( 'perf_resource' ) , // #42153, this function tests if API is working
579
- get_perf_timing ( 'perf_timing' ) ,
580
589
] ) . then ( function ( ) {
581
590
return resolve ( )
582
591
} )
0 commit comments