diff --git a/crates/nu-cli/src/config_files.rs b/crates/nu-cli/src/config_files.rs index 0d78c0ab69..2b0c46cb04 100644 --- a/crates/nu-cli/src/config_files.rs +++ b/crates/nu-cli/src/config_files.rs @@ -24,17 +24,35 @@ pub fn read_plugin_file( plugin_file: Option>, storage_path: &str, ) { - let start_time = std::time::Instant::now(); - let mut plug_path = String::new(); + let mut start_time = std::time::Instant::now(); // Reading signatures from signature file // The plugin.nu file stores the parsed signature collected from each registered plugin add_plugin_file(engine_state, plugin_file, storage_path); + perf( + "add plugin file to engine_state", + start_time, + file!(), + line!(), + column!(), + engine_state.get_config().use_ansi_coloring, + ); + start_time = std::time::Instant::now(); let plugin_path = engine_state.plugin_signatures.clone(); if let Some(plugin_path) = plugin_path { let plugin_filename = plugin_path.to_string_lossy(); - plug_path = plugin_filename.to_string(); + let plug_path = plugin_filename.to_string(); + if let Ok(contents) = std::fs::read(&plugin_path) { + perf( + &format!("read plugin file {}", &plug_path), + start_time, + file!(), + line!(), + column!(), + engine_state.get_config().use_ansi_coloring, + ); + start_time = std::time::Instant::now(); eval_source( engine_state, stack, @@ -43,17 +61,16 @@ pub fn read_plugin_file( PipelineData::empty(), false, ); + perf( + &format!("eval_source plugin file {}", &plug_path), + start_time, + file!(), + line!(), + column!(), + engine_state.get_config().use_ansi_coloring, + ); } } - - perf( - &format!("read_plugin_file {}", &plug_path), - start_time, - file!(), - line!(), - column!(), - engine_state.get_config().use_ansi_coloring, - ); } #[cfg(feature = "plugin")] diff --git a/crates/nu-cli/src/repl.rs b/crates/nu-cli/src/repl.rs index f3d609e13f..0ef7c34223 100644 --- a/crates/nu-cli/src/repl.rs +++ b/crates/nu-cli/src/repl.rs @@ -573,7 +573,7 @@ fn loop_iteration(ctx: LoopContext) -> (bool, Stack, Reedline) { run_ansi_sequence(PRE_EXECUTE_MARKER); perf( - "pre_execute_marker ansi escape sequence", + "pre_execute_marker (133;C) ansi escape sequence", start_time, file!(), line!(), @@ -583,12 +583,27 @@ fn loop_iteration(ctx: LoopContext) -> (bool, Stack, Reedline) { } // Actual command execution logic starts from here - start_time = Instant::now(); + let cmd_execution_start_time = Instant::now(); match parse_operation(s.clone(), engine_state, &stack) { Ok(operation) => match operation { ReplOperation::AutoCd { cwd, target, span } => { do_auto_cd(target, cwd, &mut stack, engine_state, span); + + if shell_integration { + start_time = Instant::now(); + + run_ansi_sequence(&get_command_finished_marker(&stack, engine_state)); + + perf( + "post_execute_marker (133;D) ansi escape sequences", + start_time, + file!(), + line!(), + column!(), + use_color, + ); + } } ReplOperation::RunCommand(cmd) => { line_editor = do_run_cmd( @@ -599,14 +614,29 @@ fn loop_iteration(ctx: LoopContext) -> (bool, Stack, Reedline) { shell_integration, *entry_num, use_color, - ) + ); + + if shell_integration { + start_time = Instant::now(); + + run_ansi_sequence(&get_command_finished_marker(&stack, engine_state)); + + perf( + "post_execute_marker (133;D) ansi escape sequences", + start_time, + file!(), + line!(), + column!(), + use_color, + ); + } } // as the name implies, we do nothing in this case ReplOperation::DoNothing => {} }, Err(ref e) => error!("Error parsing operation: {e}"), } - let cmd_duration = start_time.elapsed(); + let cmd_duration = cmd_execution_start_time.elapsed(); stack.add_env_var( "CMD_DURATION_MS".into(), @@ -991,7 +1021,6 @@ fn do_shell_integration_finalize_command( engine_state: &EngineState, stack: &mut Stack, ) { - run_ansi_sequence(&get_command_finished_marker(stack, engine_state)); if let Some(cwd) = stack.get_env_var(engine_state, "PWD") { match cwd.coerce_into_string() { Ok(path) => {