1/* 2 * Copyright (C) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15import { CatchTraceStatus } from './base/ProfilerConstant' 16 17export default class WorkerHandler { 18 static socketHandler(result) { 19 let arr = result.data.split("$") 20 switch (arr[0]) { 21 case "RAM": 22 globalThis.ramArr.push(arr[1]) 23 break; 24 case "FPS": 25 globalThis.fpsArr.push(arr[1]) 26 globalThis.fpsJitterArr.push(arr[2]) 27 globalThis.timerFps = arr[1] 28 if ( 29 globalThis.catchTraceState == CatchTraceStatus.catch_trace_start || 30 globalThis.catchTraceState == CatchTraceStatus.catch_trace_finish || 31 globalThis.catchTraceState == CatchTraceStatus.catch_trace_first_running) { 32 if (globalThis.fpsJitterArr != undefined && globalThis.fpsJitterArr != null && globalThis.fpsJitterArr != "") { 33 let tempQueue: Array<String> = globalThis.fpsJitterArr 34 let curJitter = tempQueue.pop() 35 let tempJitterArr = curJitter.split("==") 36 for (var i = 0; i < tempJitterArr.length; i++) { 37 let tmp = tempJitterArr[i] 38 let jitter = parseInt(tmp) / 1e6 39 if (jitter > 100) { 40 globalThis.jitterTrace = true 41 return 42 } 43 } 44 } 45 } 46 break; 47 case "UdpStatus": 48 let isSocketConnect = Number(arr[1]).valueOf() 49 if (isSocketConnect > 0) { 50 globalThis.useDaemon = true 51 } else { 52 globalThis.useDaemon = false 53 } 54 default: 55 break; 56 } 57 } 58}