This works perfectly, thank you very much for the help!
I tweaked it a little bit to change how the values are logged, I’ll post below what I ended up adding to my Instructions routine (which is mostly your code), in case anyone else needs it - the difference here I guess is that the interval for averaging is variable e.g. for as long as the routine is viewed:
Begin Experiment:
window.refreshCount = 0;
window.refreshStart = null;
window.refreshFinish = null;
Each Frame:
if (window.refreshStart === null) {
window.refreshStart = window.performance.now();
} else {
window.refreshFinish = window.performance.now();
window.refreshCount++;
}
console.log(window.refreshCount);
console.log(window.performance.now());
End Routine:
let duration = window.refreshFinish - window.refreshStart;
expInfo['realFrameRate'] = (duration / window.refreshCount);