MCPcopy Index your code
hub / github.com/deepnote/deepnote / recordBlockProfile

Function recordBlockProfile

packages/cli/src/commands/run.ts:1173–1207  ·  view source on GitHub ↗
(
  state: RunExecutionState,
  engine: ExecutionEngine,
  result: BlockExecutionResult,
  label: string
)

Source from the content-addressed store, hash-verified

1171}
1172
1173async function recordBlockProfile(
1174 state: RunExecutionState,
1175 engine: ExecutionEngine,
1176 result: BlockExecutionResult,
1177 label: string
1178): Promise<string> {
1179 if (!state.showProfile || !engine.serverPort) {
1180 return ''
1181 }
1182
1183 const hasBefore = state.memoryBefore.has(result.blockId)
1184 const before = state.memoryBefore.get(result.blockId)
1185 state.memoryBefore.delete(result.blockId) // Clean up
1186
1187 if (!hasBefore || before === undefined) {
1188 return ''
1189 }
1190
1191 const metrics = await fetchMetrics(engine.serverPort)
1192 if (!metrics) {
1193 return ''
1194 }
1195
1196 const delta = metrics.rss - before
1197 state.blockProfiles.push({
1198 id: result.blockId,
1199 label,
1200 durationMs: result.durationMs,
1201 memoryBefore: before,
1202 memoryAfter: metrics.rss,
1203 memoryDelta: delta,
1204 })
1205
1206 return `, ${formatMemoryDelta(delta)}`
1207}
1208
1209async function saveExecutionSnapshotBestEffort({
1210 absolutePath,

Callers 1

Calls 2

fetchMetricsFunction · 0.90
formatMemoryDeltaFunction · 0.90

Tested by

no test coverage detected