(params: {
inputPatchTypes: ReadonlyArray<TerminalPatchType>
serializedBytes: number
useSync: boolean
serializeDurationMs: number
stdoutPatchBytes: number
stdoutPatchCount: number
})
| 66 | } |
| 67 | |
| 68 | export function recordTerminalWriteStats(params: { |
| 69 | inputPatchTypes: ReadonlyArray<TerminalPatchType> |
| 70 | serializedBytes: number |
| 71 | useSync: boolean |
| 72 | serializeDurationMs: number |
| 73 | stdoutPatchBytes: number |
| 74 | stdoutPatchCount: number |
| 75 | }): void { |
| 76 | const nextCounts = { ...stats.patchTypeCounts } |
| 77 | for (const type of params.inputPatchTypes) { |
| 78 | nextCounts[type] += 1 |
| 79 | } |
| 80 | stats = { |
| 81 | ...stats, |
| 82 | writeCalls: stats.writeCalls + 1, |
| 83 | totalInputPatches: stats.totalInputPatches + params.inputPatchTypes.length, |
| 84 | maxInputPatchCount: Math.max( |
| 85 | stats.maxInputPatchCount, |
| 86 | params.inputPatchTypes.length, |
| 87 | ), |
| 88 | patchTypeCounts: nextCounts, |
| 89 | syncWrappedCalls: stats.syncWrappedCalls + (params.useSync ? 1 : 0), |
| 90 | totalSerializedBytes: stats.totalSerializedBytes + params.serializedBytes, |
| 91 | maxSerializedBytes: Math.max(stats.maxSerializedBytes, params.serializedBytes), |
| 92 | totalStdoutPatchBytes: stats.totalStdoutPatchBytes + params.stdoutPatchBytes, |
| 93 | maxStdoutPatchBytes: Math.max( |
| 94 | stats.maxStdoutPatchBytes, |
| 95 | params.stdoutPatchBytes, |
| 96 | ), |
| 97 | lastStdoutPatchBytes: params.stdoutPatchBytes, |
| 98 | lastStdoutPatchCount: params.stdoutPatchCount, |
| 99 | totalSerializeDurationMs: |
| 100 | stats.totalSerializeDurationMs + params.serializeDurationMs, |
| 101 | maxSerializeDurationMs: Math.max( |
| 102 | stats.maxSerializeDurationMs, |
| 103 | params.serializeDurationMs, |
| 104 | ), |
| 105 | lastSerializeDurationMs: params.serializeDurationMs, |
| 106 | lastSerializedBytes: params.serializedBytes, |
| 107 | lastInputPatchCount: params.inputPatchTypes.length, |
| 108 | lastUseSync: params.useSync, |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | export function getTerminalWriteStatsSnapshot(): TerminalWriteStatsSnapshot { |
| 113 | return { |
no test coverage detected