mirror of
https://gitee.com/openharmony/developtools_profiler
synced 2024-11-23 15:00:17 +00:00
modify some worker code
Signed-off-by: lwx1063336 <lixin416@huawei.com>
This commit is contained in:
parent
715d7c465a
commit
a530939d74
@ -17,9 +17,15 @@ import Ability from '@ohos.application.Ability'
|
||||
import { initDb } from '../common/database/LocalRepository'
|
||||
import { FloatWindowFun } from '../common/ui/floatwindow/FloatWindowFun'
|
||||
import { NetWork } from '../common/profiler/item/NetWork';
|
||||
import { MainWorker } from '../common/profiler/MainWorkProfiler';
|
||||
import BundleManager from '../common/utils/BundleMangerUtils';
|
||||
import display from '@ohos.display' // 导入模块
|
||||
import WorkHandler from '../common/profiler/WorkerHandler';
|
||||
import worker from '@ohos.worker'; // 导入worker模块
|
||||
|
||||
let MainWorker = new worker.Worker("/entry/ets/workers/worker.js")
|
||||
|
||||
MainWorker.onmessage = function (result) {
|
||||
WorkHandler.socketHandler(result)
|
||||
}
|
||||
|
||||
var abilityWindowStage
|
||||
export default class MainAbility extends Ability {
|
||||
@ -38,11 +44,6 @@ export default class MainAbility extends Ability {
|
||||
abilityWindowStage = windowStage;
|
||||
abilityWindowStage.setUIContent(this.context, "pages/LoginPage", null)
|
||||
globalThis.useDaemon = false
|
||||
display.getDefaultDisplay().then((disp) => {
|
||||
globalThis.screenWith = disp.width
|
||||
}, (err) => {
|
||||
console.log('display.getDefaultDisplay failed, error : ' + JSON.stringify(err));
|
||||
})
|
||||
}
|
||||
onWindowStageDestroy() {}
|
||||
onForeground() {
|
||||
@ -50,7 +51,6 @@ export default class MainAbility extends Ability {
|
||||
FloatWindowFun.initAllFun()
|
||||
NetWork.getInstance().init()
|
||||
MainWorker.postMessage({ "testConnection": true })
|
||||
|
||||
}
|
||||
onBackground() {}
|
||||
};
|
||||
|
@ -1,45 +0,0 @@
|
||||
import worker from '@ohos.worker'; // 导入worker模块
|
||||
|
||||
import {CatchTraceStatus} from './base/ProfilerConstant'
|
||||
export let MainWorker = new worker.Worker("/entry/ets/workers/worker.js")
|
||||
|
||||
MainWorker.onmessage = function (result) {
|
||||
let arr = result.data.split("$")
|
||||
switch (arr[0]) {
|
||||
case "RAM":
|
||||
globalThis.ramArr.push(arr[1])
|
||||
break;
|
||||
case "FPS":
|
||||
globalThis.fpsArr.push(arr[1])
|
||||
globalThis.fpsJitterArr.push(arr[2])
|
||||
globalThis.timerFps = arr[1]
|
||||
if (
|
||||
globalThis.catchTraceState == CatchTraceStatus.catch_trace_start ||
|
||||
globalThis.catchTraceState == CatchTraceStatus.catch_trace_finish ||
|
||||
globalThis.catchTraceState == CatchTraceStatus.catch_trace_first_running) {
|
||||
if (globalThis.fpsJitterArr != undefined && globalThis.fpsJitterArr != null && globalThis.fpsJitterArr != "") {
|
||||
let tempQueue: Array<String> = globalThis.fpsJitterArr
|
||||
let curJitter = tempQueue.pop()
|
||||
let tempJitterArr = curJitter.split("==")
|
||||
for (var i = 0; i < tempJitterArr.length; i++) {
|
||||
let tmp = tempJitterArr[i]
|
||||
let jitter = parseInt(tmp) / 1e6
|
||||
if (jitter > 100) {
|
||||
globalThis.jitterTrace = true
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "UdpStatus":
|
||||
let isSocketConnect = Number(arr[1]).valueOf()
|
||||
if (isSocketConnect > 0) {
|
||||
globalThis.useDaemon = true
|
||||
}else{
|
||||
globalThis.useDaemon = false
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
import { CatchTraceStatus } from './base/ProfilerConstant'
|
||||
export default class WorkHandler{
|
||||
|
||||
static socketHandler(result){
|
||||
let arr = result.data.split("$")
|
||||
switch (arr[0]) {
|
||||
case "RAM":
|
||||
globalThis.ramArr.push(arr[1])
|
||||
break;
|
||||
case "FPS":
|
||||
globalThis.fpsArr.push(arr[1])
|
||||
globalThis.fpsJitterArr.push(arr[2])
|
||||
globalThis.timerFps = arr[1]
|
||||
if (
|
||||
globalThis.catchTraceState == CatchTraceStatus.catch_trace_start ||
|
||||
globalThis.catchTraceState == CatchTraceStatus.catch_trace_finish ||
|
||||
globalThis.catchTraceState == CatchTraceStatus.catch_trace_first_running) {
|
||||
if (globalThis.fpsJitterArr != undefined && globalThis.fpsJitterArr != null && globalThis.fpsJitterArr != "") {
|
||||
let tempQueue: Array<String> = globalThis.fpsJitterArr
|
||||
let curJitter = tempQueue.pop()
|
||||
let tempJitterArr = curJitter.split("==")
|
||||
for (var i = 0; i < tempJitterArr.length; i++) {
|
||||
let tmp = tempJitterArr[i]
|
||||
let jitter = parseInt(tmp) / 1e6
|
||||
if (jitter > 100) {
|
||||
globalThis.jitterTrace = true
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "UdpStatus":
|
||||
let isSocketConnect = Number(arr[1]).valueOf()
|
||||
if (isSocketConnect > 0) {
|
||||
globalThis.useDaemon = true
|
||||
}else{
|
||||
globalThis.useDaemon = false
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -16,9 +16,16 @@ import { createGPData, extractNumber } from '../base/BaseProfilerUtils';
|
||||
import { BaseProfiler } from '../base/BaseProfiler'
|
||||
import { CollectorType } from '../base/ProfilerConstant'
|
||||
import { SocketProfiler } from '../base/SocketProfiler'
|
||||
import { MainWorker } from '../MainWorkProfiler'
|
||||
import SPLogger from '../../../common/utils/SPLogger'
|
||||
|
||||
import worker from '@ohos.worker'; // 导入worker模块
|
||||
import WorkHandler from '../WorkerHandler';
|
||||
let MainWorker = new worker.Worker("/entry/ets/workers/worker.js")
|
||||
|
||||
MainWorker.onmessage = function (result) {
|
||||
WorkHandler.socketHandler(result)
|
||||
}
|
||||
|
||||
export class FPS extends BaseProfiler implements SocketProfiler {
|
||||
private fpsMap: Map<String, String> = new Map
|
||||
|
||||
|
@ -16,7 +16,13 @@ import { createGPData, extractNumber } from '../base/BaseProfilerUtils';
|
||||
import { BaseProfiler } from '../base/BaseProfiler'
|
||||
import { CollectorType } from '../base/ProfilerConstant'
|
||||
import { SocketProfiler} from '../base/SocketProfiler'
|
||||
import { MainWorker } from '../MainWorkProfiler'
|
||||
import worker from '@ohos.worker'; // 导入worker模块
|
||||
import WorkHandler from '../WorkerHandler';
|
||||
let MainWorker = new worker.Worker("/entry/ets/workers/worker.js")
|
||||
|
||||
MainWorker.onmessage = function (result) {
|
||||
WorkHandler.socketHandler(result)
|
||||
}
|
||||
|
||||
export class RAM extends BaseProfiler implements SocketProfiler{
|
||||
private ramMap: Map<String, String> = new Map
|
||||
@ -53,5 +59,6 @@ export class RAM extends BaseProfiler implements SocketProfiler{
|
||||
let curRAM = ramQueue.pop()
|
||||
this.ramMap.set("pss", extractNumber(curRAM))
|
||||
}
|
||||
MainWorker.terminate()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user