Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cli): display server's time as default #480

Merged
merged 5 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions cli/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ impl<'a> FormatDisplay<'a> {
}

impl<'a> FormatDisplay<'a> {
fn running_secs(&self) -> f64 {
// prefer to show server running time
if let Some(ref stats) = self.stats {
stats.running_time_ms / 1000.0
} else {
self.start.elapsed().as_secs_f64()
}
}

async fn display_progress(&mut self, ss: &ServerStats) {
if self.settings.show_progress {
let pb = self.progress.take();
Expand Down Expand Up @@ -293,7 +302,7 @@ impl<'a> FormatDisplay<'a> {
if rows <= 1 {
rows_str = rows_str.trim_end_matches('s');
}
let rows_speed = total_rows as f64 / self.start.elapsed().as_secs_f64();
let rows_speed = total_rows as f64 / self.running_secs();
if rows_speed <= 1.0 {
rows_speed_str = rows_speed_str.trim_end_matches('s');
}
Expand All @@ -302,13 +311,13 @@ impl<'a> FormatDisplay<'a> {
rows,
rows_str,
kind,
self.start.elapsed().as_secs_f64(),
self.running_secs(),
humanize_count(total_rows as f64),
rows_str,
HumanBytes(total_bytes as u64),
humanize_count(rows_speed),
rows_speed_str,
HumanBytes((total_bytes as f64 / self.start.elapsed().as_secs_f64()) as u64),
HumanBytes((total_bytes as f64 / self.running_secs()) as u64),
);
eprintln!();
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ struct Args {
#[clap(
long,
action = ArgAction::Set,
num_args = 0..=1, require_equals = true, default_missing_value = "local",
num_args = 0..=1, require_equals = true, default_missing_value = "server",
help = "Only show execution time without results, will implicitly set output format to `null`."
)]
time: Option<TimeOption>,
Expand Down
Loading