forked from react-native-webview/react-native-webview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_worker.js
23 lines (21 loc) · 956 Bytes
/
test_worker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* eslint-disable no-restricted-globals */
/* eslint-disable no-undef */
const url = 'miniapp-resource://framework/tf-tiniapp.worker.js';
// const url = 'https://tiniapp.tikicdn.com/tiniapps/framework_files/1.81.22/worker_files/tf-tiniapp.worker.js';
const startLoadScript = Date.now();
importScripts(url);
const totalCosts = Date.now() - startLoadScript;
const importScriptsCosts = __frameworkStartTime - startLoadScript;
const loadCosts = __frameworkEndTime - __frameworkStartTime;
const { connection = { effectiveType: '4g' } } = navigator;
console.log(`connection: ${connection.effectiveType}`);
console.log(`importScripts costs: ${importScriptsCosts}ms`)
console.log(` Load script costs: ${loadCosts}ms`);
console.log(` Total costs: ${totalCosts}ms`);
console.log(` check (== 0): ${totalCosts - importScriptsCosts - loadCosts}`);
self.postMessage({
url,
connection: connection.effectiveType,
importScriptsCosts,
loadCosts,
});