(N/sec)
by
noromanba
2018-01-09 [2018/01/09 09:23:05]
timer throttling checker
-
/*
* @title (N/sec)
* @description timer throttling checker
* @include *
* @license MIT License https://opensource.org/licenses/MIT
* @javascript_url
*/
// inactive tab/window timer throttling[1]
// [1] throttling means yielding/suspending
//
// Firefox 57.0.4 | N/~1sec
// Firefox mobile 57.0.4 | N/~1sec or N/Inf(pause); Thumbnail -> switch -> Thumbnail
// Chromium 63.0.3239.108 | N/~2sec
// Edge mobile 1.0.0.1273 | N/~1sec *Blink
// backgrounds c.f.
// https://content.pivotal.io/blog/chrome-and-firefox-throttle-settimeout-setinterval-in-inactive-tabs
// https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Reasons_for_delays_longer_than_specified
// https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Timeouts_in_inactive_tabs_throttled_to_>1000ms
(async () => {
'use strict';
const sleep = (wait = 1 * 1000) => {
return new Promise(res => setTimeout(res, wait));
};
const _title = document.title;
const n = 100;
for (let i = 0; i < n; i += 1) {
const remain = String(n - i).padStart(String(n).length, '0');
const time = new Date().toTimeString().slice(0, 8);
document.title = [
'(' + remain + ')',
time,
'-',
_title,
].join(' ');
console && console.debug && console.debug(remain, time);
await sleep();
}
document.title = _title;
})();
-
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。