Skip to content

Commit 669a2b8

Browse files
factorydroidFactory Bot
authored andcommitted
fix(cli): include initial connection time in command duration
Fixes bounty issue #1521 The `cortex run` command was starting the timer after the initial connection and submission were completed, which resulted in underreported duration for commands, especially when connection setup was slow. This change moves the timer start to before the submission is sent, ensuring that the reported duration includes the full end-to-end time.
1 parent 7a104aa commit 669a2b8

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

cortex-cli/src/run_cmd.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,16 @@ impl RunCli {
532532
input_parts
533533
};
534534

535+
// Set up timeout if specified
536+
let timeout_duration = if self.timeout > 0 {
537+
Some(Duration::from_secs(self.timeout))
538+
} else {
539+
None
540+
};
541+
542+
// Start timing before submission to include connection time
543+
let start_time = std::time::Instant::now();
544+
535545
// Send the submission
536546
let submission = Submission {
537547
id: uuid::Uuid::new_v4().to_string(),
@@ -546,15 +556,6 @@ impl RunCli {
546556
let mut error_occurred = false;
547557
let mut completed = false;
548558

549-
// Set up timeout if specified
550-
let timeout_duration = if self.timeout > 0 {
551-
Some(Duration::from_secs(self.timeout))
552-
} else {
553-
None
554-
};
555-
556-
let start_time = std::time::Instant::now();
557-
558559
while let Ok(event) = handle.event_rx.recv().await {
559560
// Check timeout
560561
if let Some(timeout) = timeout_duration

cortex-engine/src/tasks/snapshot.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ impl SnapshotManager {
306306
// Write content
307307
fs::write(path, content)?;
308308

309-
// Set permissions
310309
#[cfg(unix)]
311310
if let Some(mode) = permissions {
312311
use std::os::unix::fs::PermissionsExt;

0 commit comments

Comments
 (0)