mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
fix(terminal): start precision (#3078)
* 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> * format ms as whole nums,round secs to 2 decimal places and compute all started/ended times on server and passback to clinet --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: waleed <walif6@gmail.com>
This commit is contained in:
@@ -283,7 +283,13 @@ export async function executeWorkflowCore(
|
||||
blockId: string,
|
||||
blockName: string,
|
||||
blockType: string,
|
||||
output: { input?: unknown; output: NormalizedBlockOutput; executionTime: number },
|
||||
output: {
|
||||
input?: unknown
|
||||
output: NormalizedBlockOutput
|
||||
executionTime: number
|
||||
startedAt: string
|
||||
endedAt: string
|
||||
},
|
||||
iterationContext?: IterationContext
|
||||
) => {
|
||||
await loggingSession.onBlockComplete(blockId, blockName, blockType, output)
|
||||
|
||||
@@ -103,6 +103,8 @@ export interface BlockCompletedEvent extends BaseExecutionEvent {
|
||||
input?: any
|
||||
output: any
|
||||
durationMs: number
|
||||
startedAt: string
|
||||
endedAt: string
|
||||
// Iteration context for loops and parallels
|
||||
iterationCurrent?: number
|
||||
iterationTotal?: number
|
||||
@@ -123,6 +125,8 @@ export interface BlockErrorEvent extends BaseExecutionEvent {
|
||||
input?: any
|
||||
error: string
|
||||
durationMs: number
|
||||
startedAt: string
|
||||
endedAt: string
|
||||
// Iteration context for loops and parallels
|
||||
iterationCurrent?: number
|
||||
iterationTotal?: number
|
||||
@@ -167,6 +171,19 @@ export type ExecutionEvent =
|
||||
| StreamChunkEvent
|
||||
| StreamDoneEvent
|
||||
|
||||
/**
|
||||
* Extracted data types for use in callbacks
|
||||
*/
|
||||
export type ExecutionStartedData = ExecutionStartedEvent['data']
|
||||
export type ExecutionCompletedData = ExecutionCompletedEvent['data']
|
||||
export type ExecutionErrorData = ExecutionErrorEvent['data']
|
||||
export type ExecutionCancelledData = ExecutionCancelledEvent['data']
|
||||
export type BlockStartedData = BlockStartedEvent['data']
|
||||
export type BlockCompletedData = BlockCompletedEvent['data']
|
||||
export type BlockErrorData = BlockErrorEvent['data']
|
||||
export type StreamChunkData = StreamChunkEvent['data']
|
||||
export type StreamDoneData = StreamDoneEvent['data']
|
||||
|
||||
/**
|
||||
* Helper to create SSE formatted message
|
||||
*/
|
||||
@@ -235,7 +252,13 @@ export function createSSECallbacks(options: SSECallbackOptions) {
|
||||
blockId: string,
|
||||
blockName: string,
|
||||
blockType: string,
|
||||
callbackData: { input?: unknown; output: any; executionTime: number },
|
||||
callbackData: {
|
||||
input?: unknown
|
||||
output: any
|
||||
executionTime: number
|
||||
startedAt: string
|
||||
endedAt: string
|
||||
},
|
||||
iterationContext?: { iterationCurrent: number; iterationTotal: number; iterationType: string }
|
||||
) => {
|
||||
const hasError = callbackData.output?.error
|
||||
@@ -260,6 +283,8 @@ export function createSSECallbacks(options: SSECallbackOptions) {
|
||||
input: callbackData.input,
|
||||
error: callbackData.output.error,
|
||||
durationMs: callbackData.executionTime || 0,
|
||||
startedAt: callbackData.startedAt,
|
||||
endedAt: callbackData.endedAt,
|
||||
...iterationData,
|
||||
},
|
||||
})
|
||||
@@ -276,6 +301,8 @@ export function createSSECallbacks(options: SSECallbackOptions) {
|
||||
input: callbackData.input,
|
||||
output: callbackData.output,
|
||||
durationMs: callbackData.executionTime || 0,
|
||||
startedAt: callbackData.startedAt,
|
||||
endedAt: callbackData.endedAt,
|
||||
...iterationData,
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user