@ives_xxz/framework 1.5.14 → 1.5.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/expand/FWDecorator.ts +49 -0
- package/manager/FWLayerManager.ts +3 -0
- package/package.json +1 -1
package/expand/FWDecorator.ts
CHANGED
|
@@ -367,3 +367,52 @@ export function AutoRegisterFWEvent(eventName: any) {
|
|
|
367
367
|
};
|
|
368
368
|
};
|
|
369
369
|
}
|
|
370
|
+
|
|
371
|
+
export function PerformanceMonitor(operationName?: string) {
|
|
372
|
+
return function (
|
|
373
|
+
target: any,
|
|
374
|
+
propertyKey: string,
|
|
375
|
+
descriptor: PropertyDescriptor
|
|
376
|
+
) {
|
|
377
|
+
const originalMethod = descriptor.value;
|
|
378
|
+
|
|
379
|
+
descriptor.value = async function (...args: any[]) {
|
|
380
|
+
const startTime = Date.now();
|
|
381
|
+
const moduleName = target.constructor.name;
|
|
382
|
+
let methodName = propertyKey;
|
|
383
|
+
|
|
384
|
+
if (args && args[0].type) {
|
|
385
|
+
methodName = `${methodName}->${args[0]?.type?.name}`;
|
|
386
|
+
} else {
|
|
387
|
+
methodName = operationName || propertyKey;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
try {
|
|
391
|
+
const result = await originalMethod.apply(this, args);
|
|
392
|
+
const duration = Date.now() - startTime;
|
|
393
|
+
|
|
394
|
+
FW.Entry.performanceMgr?.recordOperationMetric(
|
|
395
|
+
moduleName,
|
|
396
|
+
methodName,
|
|
397
|
+
duration
|
|
398
|
+
);
|
|
399
|
+
|
|
400
|
+
if (duration > 100) {
|
|
401
|
+
FWLog.warn(`[${moduleName}] ${methodName} took ${duration}ms`);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
return result;
|
|
405
|
+
} catch (error) {
|
|
406
|
+
const duration = Date.now() - startTime;
|
|
407
|
+
FW.Entry.performanceMgr?.recordOperationMetric(
|
|
408
|
+
moduleName,
|
|
409
|
+
`${methodName}_error`,
|
|
410
|
+
duration
|
|
411
|
+
);
|
|
412
|
+
throw error;
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
return descriptor;
|
|
417
|
+
};
|
|
418
|
+
}
|
|
@@ -11,6 +11,7 @@ import FWSocketSender from "../service/socket/FWSocketSender";
|
|
|
11
11
|
import FWSocketHandle from "../service/socket/FWSocketHandle";
|
|
12
12
|
import Framework from "../Framework";
|
|
13
13
|
import { FrameworkBase } from "../FrameworkBase";
|
|
14
|
+
import { PerformanceMonitor } from "../expand/FWDecorator";
|
|
14
15
|
|
|
15
16
|
const ADD_EXTERNAL_REFERENCE: string = "addExternalReference";
|
|
16
17
|
|
|
@@ -43,6 +44,7 @@ export class FWLayerManager extends FWManager implements FW.LayerManager {
|
|
|
43
44
|
/**
|
|
44
45
|
* 异步打开Layer
|
|
45
46
|
*/
|
|
47
|
+
@PerformanceMonitor("openAsync")
|
|
46
48
|
async openAsync<Ctr extends FW.LayerController = FW.LayerController>(
|
|
47
49
|
data: FW.LayerOpenArgs
|
|
48
50
|
): Promise<Ctr> {
|
|
@@ -52,6 +54,7 @@ export class FWLayerManager extends FWManager implements FW.LayerManager {
|
|
|
52
54
|
/**
|
|
53
55
|
* 同步打开
|
|
54
56
|
*/
|
|
57
|
+
@PerformanceMonitor("openSync")
|
|
55
58
|
openSync<Ctr extends FW.LayerController = FW.LayerController>(
|
|
56
59
|
data: FW.LayerOpenArgs
|
|
57
60
|
): Ctr {
|