Skip to content

Commit 4dbb190

Browse files
tweak (#340)
1 parent 032f8b2 commit 4dbb190

File tree

3 files changed

+34
-25
lines changed

3 files changed

+34
-25
lines changed

js/globals.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const btnList = ['alerts', 'errors', 'lies']
1919

2020
const jsFilesExpected = 14,
2121
gSectionsExpected = 16,
22-
expectedMetrics = 154
22+
expectedMetrics = 153
2323
let jsFiles = 0, gCount = 0, gCountTiming = 0
2424

2525
// global
@@ -30,7 +30,7 @@ let gData = { // from sData
3030
'perf': [],
3131
'timing': {},
3232
}
33-
let gTiming = ['currenttime','date','exslt','mark','now','timestamp']
33+
let gTiming = ['currenttime','date','exslt','mark','now','perf_timing','timestamp']
3434
let gTimeline
3535

3636
// section

js/misc.js

+29-20
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
/* TIMING */
44

55
function check_timing(type) {
6+
if ('perf_timing' == type) {return true}
7+
68
let setTiming = new Set(), value, result = true
9+
let aIgnore = [0, 1, 16, 17]
710
let max = isPerf ? 10 : 500
811
for (let i=1; i < max ; i++) {
912
try {
@@ -17,9 +20,9 @@ function check_timing(type) {
1720
} else if ('currenttime' == type) {
1821
value = (gTimeline.currentTime) - (gTimeline.currentTime)
1922
}
20-
value = Math.trunc(value)
23+
value = Math.abs(Math.trunc(value))
2124
// 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}
2326
setTiming.add(value)
2427
} catch(e) {
2528
// we would have already captured errors
@@ -44,7 +47,6 @@ function get_timing(METRIC) {
4447
} catch(e) {}
4548
try {gData.timing['date'].push((new Date())[Symbol.toPrimitive]('number'))} catch(e) {}
4649
try {gData.timing['currenttime'].push(gTimeline.currentTime)} catch(e) {}
47-
4850
/* testing
4951
gData.timing.date = [1723240561321]
5052
gData.timing.exslt = ['2024-08-09T20:23:10.000','2024-08-09T20:23:11.000']
@@ -53,8 +55,30 @@ function get_timing(METRIC) {
5355
gData.timing.currenttime = [257788.489, 258121.829, 258438.502, 259021.847]
5456
//*/
5557

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+
5679
let oGood = {
5780
'date': [0, 1, 16, 17, 33, 34],
81+
'perf_timing': [0, 1, 16, 17, 33, 34],
5882
'currenttime': [
5983
0, 0.01, 0.02, 0.03, 0.04,
6084
16.66, 16.67, 16.68, 16.69, 16.7,
@@ -184,9 +208,9 @@ function get_timing(METRIC) {
184208
data = aDiffs
185209
//console.log(k, data, isZero, is10, is100, aDiffs, aTotal)
186210
} catch(e) {
187-
str = log_error(17, METRIC +'_'+ k, e)
211+
str = zD == e ? zD : log_error(17, METRIC +'_'+ k, e)
188212
data = str
189-
oData[k] = zErr
213+
oData[k] = zD == str ? zD : zErr
190214
countFail++
191215
}
192216
//sDetail.document[METRIC][k] = data
@@ -203,20 +227,6 @@ function get_timing(METRIC) {
203227
return
204228
}
205229

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-
220230
function get_perf_resource(METRIC) {
221231
// dom.enable_resource_timing
222232
let str, data =''
@@ -576,7 +586,6 @@ const outputTiming = () => new Promise(resolve => {
576586
Promise.all([
577587
get_timing('timing_precision'),
578588
get_perf_resource('perf_resource'), // #42153, this function tests if API is working
579-
get_perf_timing('perf_timing'),
580589
]).then(function(){
581590
return resolve()
582591
})

tzp.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -919,9 +919,6 @@
919919
<div class="btn-right"></div>
920920
</td></tr>
921921
</td></tr>
922-
<tr><td><div class="ttip"><span class="icon">[ i ]</span>
923-
<span class="ttxtb">dom.enable_performance</span></div>
924-
&nbsp; performance.timing</td><td class="c mono" id="perf_timing"></td></tr>
925922
<tr><td><div class="ttip"><span class="icon">[ i ]</span>
926923
<span class="ttxtb">dom.enable_resource_timing</span></div>
927924
&nbsp; resource timing</td><td class="c mono" id="perf_resource"></td></tr>
@@ -932,6 +929,9 @@
932929
<tr class="togT"><td>EXSLT</td><td class="c mono" id="timing_precision_exslt"></td></tr>
933930
<tr class="togT"><td>mark</td><td class="c mono" id="timing_precision_mark"></td></tr>
934931
<tr class="togT"><td>now</td><td class="c mono" id="timing_precision_now"></td></tr>
932+
<tr class="togT"><td><div class="ttip"><span class="icon">[ i ]</span>
933+
<span class="ttxtb">dom.enable_performance</span></div>
934+
&nbsp; performance.timing</td><td class="c mono" id="timing_precision_perf_timing"></td></tr>
935935
<tr class="togT"><td>timestamp</td><td class="c mono" id="timing_precision_timestamp"></td></tr>
936936
</table>
937937

0 commit comments

Comments
 (0)