添加启动用时统计

main
阳光少年 1 year ago
parent 3f48637ab0
commit 1b4cf33ce8

@ -1,9 +1,10 @@
use std::{io, fs, fmt, os, path, process};
use std::{io, fs, fmt, os, path, process, time};
use io::Read;
use fmt::Display;
use os::fd::{AsFd, AsRawFd};
use os::unix::{fs::PermissionsExt, process::CommandExt};
use path::{Path, PathBuf};
use std::sync::OnceLock;
use nix::sched::{clone, CloneCb, CloneFlags, setns};
use nix::sys::{signal::{kill, Signal}, wait::{waitpid, WaitPidFlag}};
@ -25,6 +26,8 @@ static INFO_FILE: &str = "info.toml";
static mut STACK: [u8; 1024*1024*1] = [0; 1024*1024*1];
static CLONE_FLAG: i32 = 0b1101100000000100000000000000000; // CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWPID | CLONE_NEWIPC | CLONE_NEWNET;
static START_T: OnceLock<time::Instant> = OnceLock::new();
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct RockerArgs {
@ -348,6 +351,7 @@ fn start(is_wait: bool, cb: CloneCb, clong_flags: CloneFlags, container_id: &Str
break;
}
}
println!("启动用时: {}ms", START_T.get().unwrap().elapsed().as_millis());
// wait
if is_wait {
@ -611,6 +615,9 @@ fn stop_container(containers_id: &str, is_remove: bool) -> Result<()> {
fn main() -> Result<()>{
START_T.get_or_init(|| {
time::Instant::now()
});
let mut args = RockerArgs::parse();
if args.image.is_some() || args.restart.is_some() {
let volume_path;

Loading…
Cancel
Save