feat: add run cost when debug

This commit is contained in:
2022-08-06 16:02:40 +08:00
parent f85c7a68b7
commit bfed66a7ae

View File

@@ -4,6 +4,7 @@ extern crate rust_util;
use std::{env, fs, process};
use std::path::PathBuf;
use std::process::Command;
use std::time::SystemTime;
use rust_util::{util_cmd, util_msg};
use rust_util::util_msg::MessageType;
@@ -47,10 +48,14 @@ fn main() {
run_script_cmd.arg(arg);
}
debugging!("Run command: {:?}", run_script_cmd);
let run_command_start = SystemTime::now();
match util_cmd::run_command_and_wait(&mut run_script_cmd) {
Err(e) => failure_and_exit!("Run rust-script failed: {}", e),
Ok(exit_status) => {
write_script_file_to_src(script_file, cache_script_bin_name);
if let Ok(run_command_cost) = SystemTime::now().duration_since(run_command_start) {
debugging!("Run command cost: {}ms", run_command_cost.as_millis());
}
process::exit(exit_status.code().unwrap_or_else(|| 0))
}
}