fix: update StartTime to use UnixMilli for better precision across step functions

This commit is contained in:
lilong.129
2025-06-18 13:51:44 +08:00
parent 3d2707fa36
commit a890981e2d
10 changed files with 16 additions and 16 deletions
+1 -1
View File
@@ -1 +1 @@
v5.0.0-beta-2506181201 v5.0.0-beta-2506181351
+2 -2
View File
@@ -58,7 +58,7 @@ type TStep struct {
// one step contains one or multiple actions // one step contains one or multiple actions
type ActionResult struct { type ActionResult struct {
option.MobileAction `json:",inline"` option.MobileAction `json:",inline"`
StartTime int64 `json:"start_time"` // action start time StartTime int64 `json:"start_time"` // action start time in millisecond(ms)
Elapsed int64 `json:"elapsed_ms"` // action elapsed time(ms) Elapsed int64 `json:"elapsed_ms"` // action elapsed time(ms)
Error error `json:"error"` // action execution result Error error `json:"error"` // action execution result
Plannings []*uixt.PlanningExecutionResult `json:"plannings,omitempty"` // store planning results for start_to_goal actions Plannings []*uixt.PlanningExecutionResult `json:"plannings,omitempty"` // store planning results for start_to_goal actions
@@ -69,7 +69,7 @@ type ActionResult struct {
type StepResult struct { type StepResult struct {
Name string `json:"name" yaml:"name"` // step name Name string `json:"name" yaml:"name"` // step name
Identifier string `json:"identifier,omitempty" yaml:"identifier,omitempty"` // step identifier Identifier string `json:"identifier,omitempty" yaml:"identifier,omitempty"` // step identifier
StartTime int64 `json:"start_time" yaml:"time"` // step start time StartTime int64 `json:"start_time" yaml:"time"` // step start time in millisecond(ms)
StepType StepType `json:"step_type" yaml:"step_type"` // step type, testcase/request/transaction/rendezvous StepType StepType `json:"step_type" yaml:"step_type"` // step type, testcase/request/transaction/rendezvous
Success bool `json:"success" yaml:"success"` // step execution result Success bool `json:"success" yaml:"success"` // step execution result
Elapsed int64 `json:"elapsed_ms" yaml:"elapsed_ms"` // step execution time in millisecond(ms) Elapsed int64 `json:"elapsed_ms" yaml:"elapsed_ms"` // step execution time in millisecond(ms)
+1 -1
View File
@@ -54,7 +54,7 @@ func runStepFunction(r *SessionRunner, step IStep) (stepResult *StepResult, err
StepType: step.Type(), StepType: step.Type(),
Success: false, Success: false,
ContentSize: 0, ContentSize: 0,
StartTime: start.Unix(), StartTime: start.UnixMilli(),
} }
defer func() { defer func() {
attachments := uixt.Attachments{} attachments := uixt.Attachments{}
+1 -1
View File
@@ -285,7 +285,7 @@ func runStepRequest(r *SessionRunner, step IStep) (stepResult *StepResult, err e
StepType: step.Type(), StepType: step.Type(),
Success: false, Success: false,
ContentSize: 0, ContentSize: 0,
StartTime: start.Unix(), StartTime: start.UnixMilli(),
} }
defer func() { defer func() {
+1 -1
View File
@@ -95,7 +95,7 @@ func runStepShell(r *SessionRunner, step IStep) (stepResult *StepResult, err err
StepType: step.Type(), StepType: step.Type(),
Success: false, Success: false,
ContentSize: 0, ContentSize: 0,
StartTime: start.Unix(), StartTime: start.UnixMilli(),
} }
defer func() { defer func() {
stepResult.Elapsed = time.Since(start).Milliseconds() stepResult.Elapsed = time.Since(start).Milliseconds()
+1 -1
View File
@@ -51,7 +51,7 @@ func (s *StepTestCaseWithOptionalArgs) Run(r *SessionRunner) (stepResult *StepRe
Name: s.Name(), Name: s.Name(),
StepType: s.Type(), StepType: s.Type(),
Success: false, Success: false,
StartTime: start.Unix(), StartTime: start.UnixMilli(),
} }
defer func() { defer func() {
+4 -4
View File
@@ -709,7 +709,7 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
StepType: step.Type(), StepType: step.Type(),
Success: false, Success: false,
ContentSize: 0, ContentSize: 0,
StartTime: start.Unix(), StartTime: start.UnixMilli(),
} }
var stepVariables map[string]interface{} var stepVariables map[string]interface{}
@@ -781,7 +781,7 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
Method: option.ACTION_GetForegroundApp, Method: option.ACTION_GetForegroundApp,
Params: "[ForDebug] check foreground app", Params: "[ForDebug] check foreground app",
}, },
StartTime: startTime.Unix(), StartTime: startTime.UnixMilli(),
} }
subActionResults, err1 := uiDriver.ExecuteAction( subActionResults, err1 := uiDriver.ExecuteAction(
context.Background(), actionResult.MobileAction) context.Background(), actionResult.MobileAction)
@@ -815,7 +815,7 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
Method: option.ACTION_ClosePopups, Method: option.ACTION_ClosePopups,
Params: "[ForDebug] close popups handler", Params: "[ForDebug] close popups handler",
}, },
StartTime: startTime.Unix(), StartTime: startTime.UnixMilli(),
} }
subActionResults, err2 := uiDriver.ExecuteAction( subActionResults, err2 := uiDriver.ExecuteAction(
context.Background(), actionResult.MobileAction) context.Background(), actionResult.MobileAction)
@@ -844,7 +844,7 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
actionStartTime := time.Now() actionStartTime := time.Now()
actionResult := &ActionResult{ actionResult := &ActionResult{
MobileAction: action, MobileAction: action,
StartTime: actionStartTime.Unix(), // action 开始时间 StartTime: actionStartTime.UnixMilli(), // action 开始时间
} }
if action.Params, err = s.caseRunner.parser.Parse(action.Params, stepVariables); err != nil { if action.Params, err = s.caseRunner.parser.Parse(action.Params, stepVariables); err != nil {
if !code.IsErrorPredefined(err) { if !code.IsErrorPredefined(err) {
+1 -1
View File
@@ -381,7 +381,7 @@ func runStepWebSocket(r *SessionRunner, step IStep) (stepResult *StepResult, err
StepType: step.Type(), StepType: step.Type(),
Success: false, Success: false,
ContentSize: 0, ContentSize: 0,
StartTime: start.Unix(), StartTime: start.UnixMilli(),
} }
defer func() { defer func() {
+3 -3
View File
@@ -59,7 +59,7 @@ func (dExt *XTDriver) StartToGoal(ctx context.Context, prompt string, opts ...op
ModelName: "", ModelName: "",
Error: err.Error(), Error: err.Error(),
}, },
StartTime: planningStartTime.Unix(), StartTime: planningStartTime.UnixMilli(),
Elapsed: time.Since(planningStartTime).Milliseconds(), Elapsed: time.Since(planningStartTime).Milliseconds(),
} }
allPlannings = append(allPlannings, errorResult) allPlannings = append(allPlannings, errorResult)
@@ -67,7 +67,7 @@ func (dExt *XTDriver) StartToGoal(ctx context.Context, prompt string, opts ...op
} }
// Set planning execution timing // Set planning execution timing
planningResult.StartTime = planningStartTime.Unix() planningResult.StartTime = planningStartTime.UnixMilli()
planningResult.SubActions = []*SubActionResult{} planningResult.SubActions = []*SubActionResult{}
// Check if task is finished BEFORE executing actions // Check if task is finished BEFORE executing actions
@@ -96,7 +96,7 @@ func (dExt *XTDriver) StartToGoal(ctx context.Context, prompt string, opts ...op
subActionResult := &SubActionResult{ subActionResult := &SubActionResult{
ActionName: toolCall.Function.Name, ActionName: toolCall.Function.Name,
Arguments: toolCall.Function.Arguments, Arguments: toolCall.Function.Arguments,
StartTime: subActionStartTime.Unix(), StartTime: subActionStartTime.UnixMilli(),
} }
// Use defer to ensure sub-action is always processed and added to results // Use defer to ensure sub-action is always processed and added to results
+1 -1
View File
@@ -132,7 +132,7 @@ func (dExt *XTDriver) ExecuteAction(ctx context.Context, action option.MobileAct
subActionResult := &SubActionResult{ subActionResult := &SubActionResult{
ActionName: string(action.Method), ActionName: string(action.Method),
Arguments: action.Params, Arguments: action.Params,
StartTime: subActionStartTime.Unix(), StartTime: subActionStartTime.UnixMilli(),
} }
// Execute via MCP tool // Execute via MCP tool