Compare commits

..

1 Commits

Author SHA1 Message Date
Cursor Agent
49532627a1 fix(executor): use performance.now() for precise block timing
Replace Date.now() with performance.now() for timing measurements in
the executor to provide sub-millisecond precision. This fixes timing
discrepancies with fast-executing blocks like the start block where
millisecond precision was insufficient.

Changes:
- block-executor.ts: Use performance.now() for block execution timing
- engine.ts: Use performance.now() for overall execution timing

Co-authored-by: emir <emir@simstudio.ai>
2026-01-30 10:56:53 +00:00
2 changed files with 10 additions and 10 deletions

View File

@@ -71,7 +71,7 @@ export class BlockExecutor {
this.callOnBlockStart(ctx, node, block)
}
const startTime = Date.now()
const startTime = performance.now()
let resolvedInputs: Record<string, any> = {}
const nodeMetadata = this.buildNodeMetadata(node)
@@ -145,7 +145,7 @@ export class BlockExecutor {
})) as NormalizedBlockOutput
}
const duration = Date.now() - startTime
const duration = performance.now() - startTime
if (blockLog) {
blockLog.endedAt = new Date().toISOString()
@@ -221,7 +221,7 @@ export class BlockExecutor {
isSentinel: boolean,
phase: 'input_resolution' | 'execution'
): NormalizedBlockOutput {
const duration = Date.now() - startTime
const duration = performance.now() - startTime
const errorMessage = normalizeError(error)
const hasResolvedInputs =
resolvedInputs && typeof resolvedInputs === 'object' && Object.keys(resolvedInputs).length > 0

View File

@@ -101,7 +101,7 @@ export class ExecutionEngine {
}
async run(triggerBlockId?: string): Promise<ExecutionResult> {
const startTime = Date.now()
const startTime = performance.now()
try {
this.initializeQueue(triggerBlockId)
@@ -125,8 +125,8 @@ export class ExecutionEngine {
return this.buildPausedResult(startTime)
}
const endTime = Date.now()
this.context.metadata.endTime = new Date(endTime).toISOString()
const endTime = performance.now()
this.context.metadata.endTime = new Date().toISOString()
this.context.metadata.duration = endTime - startTime
if (this.cancelledFlag) {
@@ -146,8 +146,8 @@ export class ExecutionEngine {
metadata: this.context.metadata,
}
} catch (error) {
const endTime = Date.now()
this.context.metadata.endTime = new Date(endTime).toISOString()
const endTime = performance.now()
this.context.metadata.endTime = new Date().toISOString()
this.context.metadata.duration = endTime - startTime
if (this.cancelledFlag) {
@@ -433,8 +433,8 @@ export class ExecutionEngine {
}
private buildPausedResult(startTime: number): ExecutionResult {
const endTime = Date.now()
this.context.metadata.endTime = new Date(endTime).toISOString()
const endTime = performance.now()
this.context.metadata.endTime = new Date().toISOString()
this.context.metadata.duration = endTime - startTime
this.context.metadata.status = 'paused'