Skip to content

Commit

Permalink
update (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorin-Oakenpants authored Oct 3, 2024
1 parent 225a0bc commit c97b4a4
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 35 deletions.
3 changes: 2 additions & 1 deletion css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ a.return {color: var(--link); text-decoration: none; font-size: 14px; line-heig
}

/* show/hide */
.togC, .togF, .togL, .togLO, .togT, .togTM, .togTO, .togOS, .togUA1, .togUA2, .togZ {display: none;}
.togC, .togF, .togL, .togLO, .togT, .togT2, .togTM, .togTO, .togOS, .togUA1, .togUA2, .togZ {display: none;}

/* run/re-run, click here */
.btn {background-color: var(--bg0);
Expand Down Expand Up @@ -327,6 +327,7 @@ div.scrollthin {scrollbar-width: thin;}
#tb16 td:first-child {color: var(--test16);}
#tb17 td:first-child {color: var(--test17);}
#tb17 .togT td:first-child {color: var(--test99);}
#tb17 .togT2 td:first-child {color: var(--test99);}
#tb18 td:first-child {color: var(--test18);}
#tb99 td:first-child {color: var(--test99);}
#tbfp td:first-child {color: var(--test99);}
Expand Down
3 changes: 2 additions & 1 deletion js/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ function togglerows(id, word) {
let style = items[0].style.display == 'table-row' ? 'none' : 'table-row'
for (let i=0; i < items.length; i++) {items[i].style.display = style}
if ('btn' == word) {
word = '[ '+ ('none' == style ? 'show' : 'hide') +' ]'
word = '['+ ('none' == style ? '+' : '-') +']'
} else {
word = ('none' == style ? '&#9660; show ' : '&#9650; hide ') + ('' == word || word === undefined ? 'details' : word)
}
Expand Down Expand Up @@ -1682,6 +1682,7 @@ function outputUser(fn) {
} else if ('outputAudioUser' == fn) {outputAudioUser()
} else if ('get_storage_manager' == fn) { get_storage_manager()
} else if ('get_pointer_event' == fn) { get_pointer_event()
} else if ('get_timing_audio' == fn) { get_timing_audio()
}
}

Expand Down
119 changes: 94 additions & 25 deletions js/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
/* TIMING */

function check_timing(type) {
if ('performance' == type || 'resource' == type) {return true}
let aReturn = ['performance', 'resource', 'contexttime', 'performancetime']
if (aReturn.includes(type)) {return true}

let setTiming = new Set(), value, result = true
let aIgnore = [0, 1, 16, 17]
Expand Down Expand Up @@ -35,6 +36,61 @@ function check_timing(type) {
return result
}

function get_timing_audio() {
if (!gClick) {return}
gClick = false

const METRIC = 'timing_audio'
let aList = ['contexttime','performancetime'], oTime = {}, audioCtx, source, rAF

aList.forEach(function(k){
gData.timing[k] = []
oTime[k] = []
dom[METRIC +'_' + k.toLowerCase()] = ''
})
dom[METRIC].innerHTML = ''

// collect
function collectTimestamps() {
const ts = audioCtx.getOutputTimestamp();
oTime.contexttime.push(ts.contextTime * 1000)
oTime.performancetime.push(ts.performanceTime)
rAF = requestAnimationFrame(collectTimestamps); // Reregister itself
if (oTime.contexttime.length > 20) {stop()}
}

// record
try {
audioCtx = new AudioContext()
source = new AudioBufferSourceNode(audioCtx);
source.start(0);
rAF = requestAnimationFrame(collectTimestamps)
} catch(e) {
dom[METRIC].innerHTML = log_error(17, METRIC, e)
gClick = true
}

// finish
function stop() {
source.stop(0)
cancelAnimationFrame(rAF)
aList.forEach(function(k){
let data = oTime[k]
data = data.filter(function(item, position) {return data.indexOf(item) === position})
// contextTime: if the first value (we deduped) is 0 then we need to drop it
// otherwise the first diff causes an offset to our 60FPS timing as rAF catches up: e.g.
// 0, 10, 26.6, 43.3, 76.6, 110, 143.3, 160, 176.6, 193.3, 210, 243.3
// 0, 10, 26.6, 43.3
// ^ should be 0, 16.6, 33.3: i.e the [0, 10, 26.6...] we drop the start point of 0
// after that everythng is in sync
if ('contexttime' == k && 0 == data[0]) {data = data.slice(1)}
gData.timing[k] = data
get_timing(METRIC)
})
gClick = true
}
}

function get_timing_performance() {
// dom.enable_performance
try {
Expand Down Expand Up @@ -92,24 +148,27 @@ function get_timing_resource() {
}

function get_timing(METRIC) {
// check isPerf again
if (isPerf) {get_isPerf()}
get_timing_performance()
get_timing_resource()

// get a last value for each to ensure a max diff
try {gData.timing['now'].push(performance.now())} catch(e) {}
try {gData.timing['timestamp'].push(new Event('').timeStamp)} catch(e) {}
try {
gData.timing['mark'].push(performance.mark('a').startTime)
} catch(e) {}
try {gData.timing['date'].push((new Date())[Symbol.toPrimitive]('number'))} catch(e) {}
try {gData.timing['currenttime'].push(gTimeline.currentTime)} catch(e) {}
/* testing
gData.timing.date = [1723240561321]
gData.timing.exslt = ['2024-08-09T20:23:10.000','2024-08-09T20:23:11.000']
gData.timing.currenttime = [83.34, 116.72, 150, 233.4] // 60FPS but no 3 decimal places
//*/
let aLoop = ['contexttime','performancetime']
if ('timing_precision' == METRIC) {
aLoop = gTiming
// check isPerf again
if (isPerf) {get_isPerf()}
get_timing_performance()
get_timing_resource()
// get a last value for each to ensure a max diff
try {gData.timing['now'].push(performance.now())} catch(e) {}
try {gData.timing['timestamp'].push(new Event('').timeStamp)} catch(e) {}
try {
gData.timing['mark'].push(performance.mark('a').startTime)
} catch(e) {}
try {gData.timing['date'].push((new Date())[Symbol.toPrimitive]('number'))} catch(e) {}
try {gData.timing['currenttime'].push(gTimeline.currentTime)} catch(e) {}
/* testing
gData.timing.date = [1723240561321]
gData.timing.exslt = ['2024-08-09T20:23:10.000','2024-08-09T20:23:11.000']
gData.timing.currenttime = [83.34, 116.72, 150, 233.4] // 60FPS but no 3 decimal places
//*/
}

let oGood = {
'date': [0, 1, 16, 17, 33, 34],
Expand All @@ -133,7 +192,7 @@ function get_timing(METRIC) {
sDetail.document[METRIC +'_data'] = {}
let isDateNoise = false

gTiming.forEach(function(k){
aLoop.forEach(function(k){
let aGood = oGood[k]
if (undefined == aGood) {aGood = oGood.other}
// don't add to health, we do that with the parent metric
Expand Down Expand Up @@ -247,16 +306,26 @@ function get_timing(METRIC) {
if (zSKIP !== e) {countFail++} else {notation = ''}
}
//sDetail.document[METRIC][k] = data
addDisplay(17, METRIC +'_'+ k, str,'', notation)
if ('timing_precision' == METRIC) {
addDisplay(17, METRIC +'_'+ k, str,'', notation)
} else {
dom[METRIC +'_'+ k].innerHTML = str + (isSmart ? notation : '')
}
})
// display
let countProtected = gTiming.length - countFail
let isProtected = countProtected == gTiming.length
let countProtected = aLoop.length - countFail
let isProtected = countProtected == aLoop.length
notation = isProtected ? rfp_green : rfp_red
str = countProtected +'/' + gTiming.length
str = countProtected +'/' + aLoop.length
let btn = addButton(17, METRIC, str) + addButton(17, METRIC +'_data', 'data')
// data
addBoth(17, METRIC, mini(oData), btn, notation, oData)
if ('timing_precision' == METRIC) {
addBoth(17, METRIC, mini(oData), btn, notation, oData)
} else {
sDetail.document[METRIC] = oData
dom[METRIC].innerHTML = mini(oData) + btn + (isSmart ? notation : '')
gClick = false
}
return
}

Expand Down
23 changes: 15 additions & 8 deletions tzp.html
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@
<tr><td id="lvendor">vendor</td><td class="c mono spaces" id="vendor"></td></tr>
<tr><td id="lvendorSub">vendorSub</td><td class="c mono spaces" id="vendorSub"></td></tr>
<tr><td colspan="2" class="center">--- other methods ---</td></tr>
<tr><td><span id="labelUA1" class="btn btn0" onClick="togglerows('UA1','btn')">[ show ]</span>
<tr><td><span id="labelUA1" class="btn btn0" onClick="togglerows('UA1','btn')">[+]</span>
iframes <sup>1</sup></td><td class="c mono" id="uaIframes"></td></tr>
<tr class="togUA1"><td>[contentWindow] document root</td><td class="c mono" id="ua_content_docroot"></td></tr>
<tr class="togUA1"><td>[contentWindow] with URL</td><td class="c mono" id="ua_content_with_url"></td></tr>
Expand All @@ -341,7 +341,7 @@
<tr class="togUA1"><td>iframe access</td><td class="c mono" id="ua_iframe_access"></td></tr>
<tr class="togUA1"><td>nested</td><td class="c mono" id="ua_nested"></td></tr>
<tr class="togUA1"><td>window access</td><td class="c mono" id="ua_window_access"></td></tr>
<tr><td><span id="labelUA2" class="btn btn0" onClick="togglerows('UA2','btn')">[ show ]</span>
<tr><td><span id="labelUA2" class="btn btn0" onClick="togglerows('UA2','btn')">[+]</span>
workers</td><td class="mono s99" id="uaWorkers">summary not coded</td></tr>
<tr class="togUA2"><td>web worker</td><td class="c mono" id="uaWorker0"></td></tr>
<tr class="togUA2"><td>shared worker</td><td class="c mono" id="uaWorker1"></td></tr>
Expand Down Expand Up @@ -419,7 +419,7 @@
<tr><td>language</td><td class="c mono" id="language"></td></tr>
<tr><td>languages</td><td class="c mono" id="languages"></td></tr>
<!--locale-->
<tr><td><span id="labelLO" class="btn btn0" onClick="togglerows('LO','btn')">[ show ]</span>
<tr><td><span id="labelLO" class="btn btn0" onClick="togglerows('LO','btn')">[+]</span>
locale</td><td class="c mono" id="locale"></td></tr>
<tr class="togLO"><td><div class="ttip"><span class="icon">[ i ]</span>
<span class="ttxt">Collator<br>DateTimeFormat<br>DisplayNames<br>ListFormat<br>NumberFormat<br>PluralRules
Expand All @@ -439,15 +439,15 @@
<tr><td>XSLT messages</td><td class="c mono" id="xslt_messages"></td></tr>
<!--tz-->
<tr><td>timezone</td><td class="c mono" id="timezone"></td></tr>
<tr><td><span id="labelTM" class="btn btn0" onClick="togglerows('TM','btn')">[ show ]</span>
<tr><td><span id="labelTM" class="btn btn0" onClick="togglerows('TM','btn')">[+]</span>
[offset] timezone</td><td class="c mono" id="timezone_offset"></td></tr>
<tr class="togTM"><td>date</td><td class="c mono" id="timezone_offset_date"></td></tr>
<tr class="togTM"><td>control date</td><td class="c mono" id="timezone_offset_control"></td></tr>
<tr class="togTM"><td>iframe</td><td class="c mono" id="timezone_offset_iframe"></td></tr>
<tr class="togTM"><td>parseFromString</td><td class="c mono" id="timezone_offset_string"></td></tr>
<tr class="togTM"><td>parseHTMLUnsafe</td><td class="c mono" id="timezone_offset_unsafe"></td></tr>
<tr class="togTM"><td>EXSLT</td><td class="c mono" id="timezone_offset_exslt"></td></tr>
<tr><td><span id="labelTO" class="btn btn0" onClick="togglerows('TO','btn')">[ show ]</span>
<tr><td><span id="labelTO" class="btn btn0" onClick="togglerows('TO','btn')">[+]</span>
[offsets] timezone</td><td class="c mono" id="timezone_offsets"></td></tr>
<tr class="togTO"><td>date</td><td class="c mono" id="date"></td></tr>
<tr class="togTO"><td><a class="blue" href="tests/timezones.html" target="blank">[PoC]</a>
Expand Down Expand Up @@ -718,7 +718,7 @@
<!--fonts-->
<tr><td></td><td><span class="s12">fonts</span></td></tr>
<tr><td>[groups] fonts <sup>3</sup></td><td class="c mono" id="font_sizes_groups"></td></tr>
<tr><td><span id="labelF" class="btn btn0" onClick="togglerows('F','btn')">[ show ]</span>
<tr><td><span id="labelF" class="btn btn0" onClick="togglerows('F','btn')">[+]</span>
[sizes | names] fonts <sup>3</sup></td>
<td class="mono"><span class="c" id="font_sizes"></span> | <span class="c" id="font_names"></span></td>
</tr>
Expand Down Expand Up @@ -825,7 +825,7 @@
<tr><td>[deprecated] colors</td><td class="c mono" id="colors_deprecated"></td></tr>
<tr><td><a class="blue" href="tests/csscolors.html" target="blank">[PoC]</a>
&nbsp; [-moz-] colors</td><td class="c mono" id="colors_moz"></td></tr>
<tr><td><span id="labelC" class="btn btn0" onClick="togglerows('C','btn')">[ show ]</span>
<tr><td><span id="labelC" class="btn btn0" onClick="togglerows('C','btn')">[+]</span>
computed styles <sup>1</sup></td><td class="c mono" id="computed_styles"></td></tr>
<tr class="togC"><td>CSSRuleList.style <sup>1</sup></td><td class="c mono" id="computed_styles_cssrulelist"></td></tr>
<tr class="togC"><td>DOMParser <sup>1</sup></td><td class="c mono" id="computed_styles_domparser"></td></tr>
Expand Down Expand Up @@ -918,7 +918,14 @@
<span class="c" id="timinghash"></span>
<div class="btn-right"></div>
</td></tr>
<tr><td><span id="labelT" class="btn btn0" onClick="togglerows('T','btn')">[ show ]</span>
<!--manual-->
<tr><td><span class="btn btn0" onClick="outputUser('get_timing_audio')">[ click ]</span>
<span id="labelT2" class="btn btn0" onClick="togglerows('T2','btn')">[+]</span>
audio</td><td class="c mono" id="timing_audio"></td></tr>
<tr class="togT2"><td>contexttime</td><td class="c mono" id="timing_audio_contexttime"></td></tr>
<tr class="togT2"><td>performancetime</td><td class="c mono" id="timing_audio_performancetime"></td></tr>
<!--auto-->
<tr><td><span id="labelT" class="btn btn0" onClick="togglerows('T','btn')">[+]</span>
timing precision</td><td class="c mono" id="timing_precision"></td></tr>
<tr class="togT"><td>currenttime</td><td class="c mono" id="timing_precision_currenttime"></td></tr>
<tr class="togT"><td>date</td><td class="c mono" id="timing_precision_date"></td></tr>
Expand Down

0 comments on commit c97b4a4

Please sign in to comment.