diff options
author | RaindropsSys <contact@minteck.org> | 2023-06-22 23:06:12 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-06-22 23:06:12 +0200 |
commit | 23563c7188e089929b60f9e10721c6fc43a220ff (patch) | |
tree | edfe2b009c82900d4ac27db02222d2f68dcad846 /includes/external/school/node_modules/w3c-hr-time/lib/clock-is-accurate.js | |
parent | 7a7a49332df7c852abbaa33c7e8e87f93d064d61 (diff) | |
download | pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.tar.gz pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.tar.bz2 pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.zip |
Updated 15 files, added includes/maintenance/deleteUnusedAssets.php and deleted 4944 files (automated)
Diffstat (limited to 'includes/external/school/node_modules/w3c-hr-time/lib/clock-is-accurate.js')
-rw-r--r-- | includes/external/school/node_modules/w3c-hr-time/lib/clock-is-accurate.js | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/includes/external/school/node_modules/w3c-hr-time/lib/clock-is-accurate.js b/includes/external/school/node_modules/w3c-hr-time/lib/clock-is-accurate.js deleted file mode 100644 index 920b499..0000000 --- a/includes/external/school/node_modules/w3c-hr-time/lib/clock-is-accurate.js +++ /dev/null @@ -1,61 +0,0 @@ -"use strict"; - -const { hrtime } = require("./utils"); - -// The HR-TIME spec calls for 5-μs accuracy. Check that we have that in both hrtime() and Date.now(). - -function testClockAccuracy() { - // Test hrtime() first. The check is simpler and more stable, and we use hrtime() to measure Date.now()'s performance. - const roundTrip = hrtime(hrtime()); - if (roundTrip[0] > 1 || roundTrip[1] > 5e3 * 2) { - return false; - } - - // Test Date.now() twice: first with a looser bound (10 μs) but with a smaller run time to filter out very bad - // Date.now() performance, and then with a tighter bound (5 μs) to check we have the accuracy we need. - let times; - // eslint-disable-next-line no-unused-vars - let cur; - let start; - let end; - - times = 100; - start = hrtime(); - while (times-- > 0) { - cur = Date.now(); - } - end = hrtime(start); - if ((end[0] * 1e9 + end[1]) > 1000000) { - return false; - } - - times = 10000; - start = hrtime(); - while (times-- > 0) { - cur = Date.now(); - } - end = hrtime(start); - if ((end[0] * 1e9 + end[1]) > 50000000) { - return false; - } - - return true; -} - -// Warm up the function. -testClockAccuracy(); -testClockAccuracy(); -testClockAccuracy(); - -const TIMES = 5; -const THRESHOLD = 0.6 * TIMES; -let accurates = 0; -for (let i = 0; i < TIMES; i++) { - if (testClockAccuracy()) { - accurates++; - } -} - -const isAccurate = accurates >= THRESHOLD; - -module.exports = isAccurate; |