( app: App, uid: number, instance: ComponentInstance, type: string, time: number, ctx: BackendContext, )
| 15 | }>() |
| 16 | |
| 17 | export async function performanceMarkStart( |
| 18 | app: App, |
| 19 | uid: number, |
| 20 | instance: ComponentInstance, |
| 21 | type: string, |
| 22 | time: number, |
| 23 | ctx: BackendContext, |
| 24 | ) { |
| 25 | try { |
| 26 | if (!SharedData.performanceMonitoringEnabled) { |
| 27 | return |
| 28 | } |
| 29 | const appRecord = await getAppRecord(app, ctx) |
| 30 | if (!appRecord) { |
| 31 | return |
| 32 | } |
| 33 | const componentName = await appRecord.backend.api.getComponentName(instance) |
| 34 | const groupId = ctx.perfUniqueGroupId++ |
| 35 | const groupKey = `${uid}-${type}` |
| 36 | appRecord.perfGroupIds.set(groupKey, { groupId, time }) |
| 37 | await addTimelineEvent({ |
| 38 | layerId: 'performance', |
| 39 | event: { |
| 40 | time, |
| 41 | data: { |
| 42 | component: componentName, |
| 43 | type, |
| 44 | measure: 'start', |
| 45 | }, |
| 46 | title: componentName, |
| 47 | subtitle: type, |
| 48 | groupId, |
| 49 | }, |
| 50 | }, app, ctx) |
| 51 | |
| 52 | if (markEndQueue.has(groupKey)) { |
| 53 | const { |
| 54 | app, |
| 55 | uid, |
| 56 | instance, |
| 57 | type, |
| 58 | time, |
| 59 | } = markEndQueue.get(groupKey) |
| 60 | markEndQueue.delete(groupKey) |
| 61 | await performanceMarkEnd( |
| 62 | app, |
| 63 | uid, |
| 64 | instance, |
| 65 | type, |
| 66 | time, |
| 67 | ctx, |
| 68 | ) |
| 69 | } |
| 70 | } |
| 71 | catch (e) { |
| 72 | if (SharedData.debugInfo) { |
| 73 | console.error(e) |
| 74 | } |
no test coverage detected