mirror of
https://github.com/nushell/nushell
synced 2024-12-26 04:53:09 +00:00
print nushell startup time (#7831)
# Description This PR shows the startup time and decreases the banner. This startup time output can be disabled with the `show_banner: false` setting in the config. This is the startup in debug mode. ![image](https://user-images.githubusercontent.com/343840/213955410-f319f8d4-1f96-47ae-8366-1c564a08d3e4.png) On my mac in release mode ``` Startup Time: 368ms 429µs 83ns ``` On my mac without a config as `nu --config foo --env-config foo` ``` Startup Time: 11ms 663µs 791ns ``` I could really go either way on this. If people don't like this change, we don't have to merge it. # User-Facing Changes Startup Time # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date.
This commit is contained in:
parent
4bac90a3b2
commit
ef660be285
6 changed files with 63 additions and 78 deletions
24
Cargo.lock
generated
24
Cargo.lock
generated
|
@ -1233,16 +1233,6 @@ version = "0.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
|
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fancy-regex"
|
|
||||||
version = "0.10.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0678ab2d46fa5195aaf59ad034c083d351377d4af57f3e073c074d0da3e3c766"
|
|
||||||
dependencies = [
|
|
||||||
"bit-set",
|
|
||||||
"regex",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fancy-regex"
|
name = "fancy-regex"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
|
@ -2118,9 +2108,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.135"
|
version = "0.2.139"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c"
|
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libgit2-sys"
|
name = "libgit2-sys"
|
||||||
|
@ -2674,7 +2664,7 @@ dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"chrono",
|
"chrono",
|
||||||
"crossterm 0.24.0",
|
"crossterm 0.24.0",
|
||||||
"fancy-regex 0.10.0",
|
"fancy-regex",
|
||||||
"fuzzy-matcher",
|
"fuzzy-matcher",
|
||||||
"is_executable",
|
"is_executable",
|
||||||
"log",
|
"log",
|
||||||
|
@ -2732,7 +2722,7 @@ dependencies = [
|
||||||
"dtparse",
|
"dtparse",
|
||||||
"eml-parser",
|
"eml-parser",
|
||||||
"encoding_rs",
|
"encoding_rs",
|
||||||
"fancy-regex 0.10.0",
|
"fancy-regex",
|
||||||
"filesize",
|
"filesize",
|
||||||
"filetime",
|
"filetime",
|
||||||
"fs_extra",
|
"fs_extra",
|
||||||
|
@ -2916,7 +2906,7 @@ dependencies = [
|
||||||
"byte-unit",
|
"byte-unit",
|
||||||
"chrono",
|
"chrono",
|
||||||
"chrono-humanize",
|
"chrono-humanize",
|
||||||
"fancy-regex 0.11.0",
|
"fancy-regex",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"lru",
|
"lru",
|
||||||
"miette",
|
"miette",
|
||||||
|
@ -5399,9 +5389,9 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.4"
|
version = "1.0.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd"
|
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-linebreak"
|
name = "unicode-linebreak"
|
||||||
|
|
47
Cargo.toml
47
Cargo.toml
|
@ -45,21 +45,21 @@ ctrlc = "3.2.1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
miette = { version = "5.5.0", features = ["fancy-no-backtrace"] }
|
miette = { version = "5.5.0", features = ["fancy-no-backtrace"] }
|
||||||
nu-ansi-term = "0.46.0"
|
nu-ansi-term = "0.46.0"
|
||||||
nu-cli = { path="./crates/nu-cli", version = "0.74.1" }
|
nu-cli = { path = "./crates/nu-cli", version = "0.74.1" }
|
||||||
nu-color-config = { path = "./crates/nu-color-config", version = "0.74.1" }
|
nu-color-config = { path = "./crates/nu-color-config", version = "0.74.1" }
|
||||||
nu-command = { path="./crates/nu-command", version = "0.74.1" }
|
nu-command = { path = "./crates/nu-command", version = "0.74.1" }
|
||||||
nu-engine = { path="./crates/nu-engine", version = "0.74.1" }
|
nu-engine = { path = "./crates/nu-engine", version = "0.74.1" }
|
||||||
nu-json = { path="./crates/nu-json", version = "0.74.1" }
|
nu-json = { path = "./crates/nu-json", version = "0.74.1" }
|
||||||
nu-parser = { path="./crates/nu-parser", version = "0.74.1" }
|
nu-parser = { path = "./crates/nu-parser", version = "0.74.1" }
|
||||||
nu-path = { path="./crates/nu-path", version = "0.74.1" }
|
nu-path = { path = "./crates/nu-path", version = "0.74.1" }
|
||||||
nu-plugin = { path = "./crates/nu-plugin", optional = true, version = "0.74.1" }
|
nu-plugin = { path = "./crates/nu-plugin", optional = true, version = "0.74.1" }
|
||||||
nu-pretty-hex = { path = "./crates/nu-pretty-hex", version = "0.74.1" }
|
nu-pretty-hex = { path = "./crates/nu-pretty-hex", version = "0.74.1" }
|
||||||
nu-protocol = { path = "./crates/nu-protocol", version = "0.74.1" }
|
nu-protocol = { path = "./crates/nu-protocol", version = "0.74.1" }
|
||||||
nu-system = { path = "./crates/nu-system", version = "0.74.1" }
|
nu-system = { path = "./crates/nu-system", version = "0.74.1" }
|
||||||
nu-table = { path = "./crates/nu-table", version = "0.74.1" }
|
nu-table = { path = "./crates/nu-table", version = "0.74.1" }
|
||||||
nu-term-grid = { path = "./crates/nu-term-grid", version = "0.74.1" }
|
nu-term-grid = { path = "./crates/nu-term-grid", version = "0.74.1" }
|
||||||
nu-utils = { path = "./crates/nu-utils", version = "0.74.1" }
|
nu-utils = { path = "./crates/nu-utils", version = "0.74.1" }
|
||||||
reedline = { version = "0.14.0", features = ["bashisms", "sqlite"]}
|
reedline = { version = "0.14.0", features = ["bashisms", "sqlite"] }
|
||||||
|
|
||||||
rayon = "1.6.1"
|
rayon = "1.6.1"
|
||||||
is_executable = "1.0.1"
|
is_executable = "1.0.1"
|
||||||
|
@ -76,22 +76,29 @@ signal-hook = { version = "0.3.14", default-features = false }
|
||||||
winres = "0.1"
|
winres = "0.1"
|
||||||
|
|
||||||
[target.'cfg(target_family = "unix")'.dependencies]
|
[target.'cfg(target_family = "unix")'.dependencies]
|
||||||
nix = { version = "0.25", default-features = false, features = ["signal", "process", "fs", "term"]}
|
nix = { version = "0.25", default-features = false, features = ["signal", "process", "fs", "term"] }
|
||||||
atty = "0.2"
|
atty = "0.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
nu-test-support = { path="./crates/nu-test-support", version = "0.74.1" }
|
nu-test-support = { path = "./crates/nu-test-support", version = "0.74.1" }
|
||||||
tempfile = "3.2.0"
|
tempfile = "3.2.0"
|
||||||
assert_cmd = "2.0.2"
|
assert_cmd = "2.0.2"
|
||||||
criterion = "0.4"
|
criterion = "0.4"
|
||||||
pretty_assertions = "1.0.0"
|
pretty_assertions = "1.0.0"
|
||||||
serial_test = "0.10.0"
|
serial_test = "0.10.0"
|
||||||
hamcrest2 = "0.3.0"
|
hamcrest2 = "0.3.0"
|
||||||
rstest = {version = "0.15.0", default-features = false}
|
rstest = { version = "0.15.0", default-features = false }
|
||||||
itertools = "0.10.3"
|
itertools = "0.10.3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
plugin = ["nu-plugin", "nu-cli/plugin", "nu-parser/plugin", "nu-command/plugin", "nu-protocol/plugin", "nu-engine/plugin"]
|
plugin = [
|
||||||
|
"nu-plugin",
|
||||||
|
"nu-cli/plugin",
|
||||||
|
"nu-parser/plugin",
|
||||||
|
"nu-command/plugin",
|
||||||
|
"nu-protocol/plugin",
|
||||||
|
"nu-engine/plugin",
|
||||||
|
]
|
||||||
# extra used to be more useful but now it's the same as default. Leaving it in for backcompat with existing build scripts
|
# extra used to be more useful but now it's the same as default. Leaving it in for backcompat with existing build scripts
|
||||||
extra = ["default"]
|
extra = ["default"]
|
||||||
default = ["plugin", "which-support", "trash-support", "sqlite"]
|
default = ["plugin", "which-support", "trash-support", "sqlite"]
|
||||||
|
@ -114,7 +121,7 @@ dataframe = ["nu-command/dataframe"]
|
||||||
sqlite = ["nu-command/sqlite"]
|
sqlite = ["nu-command/sqlite"]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = "s" # Optimize for size
|
opt-level = "s" # Optimize for size
|
||||||
strip = "debuginfo"
|
strip = "debuginfo"
|
||||||
lto = "thin"
|
lto = "thin"
|
||||||
|
|
||||||
|
@ -147,4 +154,4 @@ reedline = { git = "https://github.com/nushell/reedline.git", branch = "main" }
|
||||||
# Run individual benchmarks like `cargo bench -- <regex>` e.g. `cargo bench -- parse`
|
# Run individual benchmarks like `cargo bench -- <regex>` e.g. `cargo bench -- parse`
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "benchmarks"
|
name = "benchmarks"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
|
@ -8,24 +8,24 @@ name = "nu-cli"
|
||||||
version = "0.74.1"
|
version = "0.74.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
nu-test-support = { path="../nu-test-support", version = "0.74.1" }
|
nu-test-support = { path = "../nu-test-support", version = "0.74.1" }
|
||||||
nu-command = { path = "../nu-command", version = "0.74.1" }
|
nu-command = { path = "../nu-command", version = "0.74.1" }
|
||||||
rstest = {version = "0.15.0", default-features = false}
|
rstest = { version = "0.15.0", default-features = false }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-engine = { path = "../nu-engine", version = "0.74.1" }
|
nu-engine = { path = "../nu-engine", version = "0.74.1" }
|
||||||
nu-path = { path = "../nu-path", version = "0.74.1" }
|
nu-path = { path = "../nu-path", version = "0.74.1" }
|
||||||
nu-parser = { path = "../nu-parser", version = "0.74.1" }
|
nu-parser = { path = "../nu-parser", version = "0.74.1" }
|
||||||
nu-protocol = { path = "../nu-protocol", version = "0.74.1" }
|
nu-protocol = { path = "../nu-protocol", version = "0.74.1" }
|
||||||
nu-utils = { path = "../nu-utils", version = "0.74.1" }
|
nu-utils = { path = "../nu-utils", version = "0.74.1" }
|
||||||
nu-ansi-term = "0.46.0"
|
nu-ansi-term = "0.46.0"
|
||||||
nu-color-config = { path = "../nu-color-config", version = "0.74.1" }
|
nu-color-config = { path = "../nu-color-config", version = "0.74.1" }
|
||||||
reedline = { version = "0.14.0", features = ["bashisms", "sqlite"]}
|
reedline = { version = "0.14.0", features = ["bashisms", "sqlite"] }
|
||||||
|
|
||||||
atty = "0.2.14"
|
atty = "0.2.14"
|
||||||
chrono = { default-features = false, features = ["std"], version = "0.4.23" }
|
chrono = { default-features = false, features = ["std"], version = "0.4.23" }
|
||||||
crossterm = "0.24.0"
|
crossterm = "0.24.0"
|
||||||
fancy-regex = "0.10.0"
|
fancy-regex = "0.11.0"
|
||||||
fuzzy-matcher = "0.3.7"
|
fuzzy-matcher = "0.3.7"
|
||||||
is_executable = "1.0.1"
|
is_executable = "1.0.1"
|
||||||
once_cell = "1.17.0"
|
once_cell = "1.17.0"
|
||||||
|
|
|
@ -41,6 +41,7 @@ pub fn evaluate_repl(
|
||||||
stack: &mut Stack,
|
stack: &mut Stack,
|
||||||
nushell_path: &str,
|
nushell_path: &str,
|
||||||
prerun_command: Option<Spanned<String>>,
|
prerun_command: Option<Spanned<String>>,
|
||||||
|
start_time: Instant,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
use reedline::{FileBackedHistory, Reedline, Signal};
|
use reedline::{FileBackedHistory, Reedline, Signal};
|
||||||
|
|
||||||
|
@ -307,6 +308,13 @@ pub fn evaluate_repl(
|
||||||
column!()
|
column!()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if entry_num == 1 && show_banner {
|
||||||
|
println!(
|
||||||
|
"Startup Time: {}",
|
||||||
|
format_duration(start_time.elapsed().as_nanos() as i64)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let input = line_editor.read_line(prompt);
|
let input = line_editor.read_line(prompt);
|
||||||
let shell_integration = config.shell_integration;
|
let shell_integration = config.shell_integration;
|
||||||
|
|
||||||
|
@ -578,15 +586,7 @@ Our {}Documentation{} is located at {}http://nushell.sh{}
|
||||||
{}Tweet{} us at {}@nu_shell{}
|
{}Tweet{} us at {}@nu_shell{}
|
||||||
|
|
||||||
It's been this long since {}Nushell{}'s first commit:
|
It's been this long since {}Nushell{}'s first commit:
|
||||||
{}
|
{}{}
|
||||||
|
|
||||||
{}You can disable this banner using the {}config nu{}{} command
|
|
||||||
to modify the config.nu file and setting show_banner to false.
|
|
||||||
|
|
||||||
let-env config = {{
|
|
||||||
show_banner: false
|
|
||||||
...
|
|
||||||
}}{}
|
|
||||||
"#,
|
"#,
|
||||||
"\x1b[32m", //start line 1 green
|
"\x1b[32m", //start line 1 green
|
||||||
"\x1b[32m", //start line 2
|
"\x1b[32m", //start line 2
|
||||||
|
@ -618,11 +618,7 @@ let-env config = {{
|
||||||
"\x1b[32m", //before Nushell
|
"\x1b[32m", //before Nushell
|
||||||
"\x1b[0m", //after Nushell
|
"\x1b[0m", //after Nushell
|
||||||
age,
|
age,
|
||||||
"\x1b[2;37m", //before banner disable dim white
|
"\x1b[0m", //after banner disable
|
||||||
"\x1b[2;36m", //before config nu dim cyan
|
|
||||||
"\x1b[0m", //after config nu
|
|
||||||
"\x1b[2;37m", //after config nu dim white
|
|
||||||
"\x1b[0m", //after banner disable
|
|
||||||
);
|
);
|
||||||
|
|
||||||
banner
|
banner
|
||||||
|
|
|
@ -34,10 +34,7 @@ base64 = "0.21.0"
|
||||||
byteorder = "1.4.3"
|
byteorder = "1.4.3"
|
||||||
bytesize = "1.1.0"
|
bytesize = "1.1.0"
|
||||||
calamine = "0.19.1"
|
calamine = "0.19.1"
|
||||||
chrono = { version = "0.4.23", features = [
|
chrono = { version = "0.4.23", features = ["unstable-locales", "std"], default-features = false }
|
||||||
"unstable-locales",
|
|
||||||
"std",
|
|
||||||
], default-features = false }
|
|
||||||
chrono-humanize = "0.2.1"
|
chrono-humanize = "0.2.1"
|
||||||
chrono-tz = "0.6.3"
|
chrono-tz = "0.6.3"
|
||||||
crossterm = "0.24.0"
|
crossterm = "0.24.0"
|
||||||
|
@ -47,7 +44,7 @@ digest = { default-features = false, version = "0.10.0" }
|
||||||
dtparse = "1.2.0"
|
dtparse = "1.2.0"
|
||||||
eml-parser = "0.1.0"
|
eml-parser = "0.1.0"
|
||||||
encoding_rs = "0.8.30"
|
encoding_rs = "0.8.30"
|
||||||
fancy-regex = "0.10.0"
|
fancy-regex = "0.11.0"
|
||||||
filesize = "0.2.0"
|
filesize = "0.2.0"
|
||||||
filetime = "0.2.15"
|
filetime = "0.2.15"
|
||||||
fs_extra = "1.2.0"
|
fs_extra = "1.2.0"
|
||||||
|
@ -59,9 +56,7 @@ Inflector = "0.11"
|
||||||
is-root = "0.1.2"
|
is-root = "0.1.2"
|
||||||
itertools = "0.10.0"
|
itertools = "0.10.0"
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
lscolors = { version = "0.12.0", features = [
|
lscolors = { version = "0.12.0", features = ["crossterm"], default-features = false }
|
||||||
"crossterm",
|
|
||||||
], default-features = false }
|
|
||||||
md5 = { package = "md-5", version = "0.10.0" }
|
md5 = { package = "md-5", version = "0.10.0" }
|
||||||
mime = "0.3.16"
|
mime = "0.3.16"
|
||||||
mime_guess = "2.0.4"
|
mime_guess = "2.0.4"
|
||||||
|
@ -147,20 +142,14 @@ features = [
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies.windows]
|
[target.'cfg(windows)'.dependencies.windows]
|
||||||
version = "0.43.0"
|
version = "0.43.0"
|
||||||
features = [
|
features = ["Win32_Foundation", "Win32_Storage_FileSystem", "Win32_System_SystemServices"]
|
||||||
"Win32_Foundation",
|
|
||||||
"Win32_Storage_FileSystem",
|
|
||||||
"Win32_System_SystemServices",
|
|
||||||
]
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
trash-support = ["trash"]
|
trash-support = ["trash"]
|
||||||
which-support = ["which"]
|
which-support = ["which"]
|
||||||
plugin = ["nu-parser/plugin"]
|
plugin = ["nu-parser/plugin"]
|
||||||
dataframe = ["polars", "num", "sqlparser"]
|
dataframe = ["polars", "num", "sqlparser"]
|
||||||
sqlite = [
|
sqlite = ["rusqlite"] # TODO: given that rusqlite is included in reedline, should we just always include it?
|
||||||
"rusqlite",
|
|
||||||
] # TODO: given that rusqlite is included in reedline, should we just always include it?
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
shadow-rs = { version = "0.20.0", default-features = false }
|
shadow-rs = { version = "0.20.0", default-features = false }
|
||||||
|
|
|
@ -27,13 +27,15 @@ use nu_command::create_default_context;
|
||||||
use nu_parser::{escape_for_script_arg, escape_quote_string};
|
use nu_parser::{escape_for_script_arg, escape_quote_string};
|
||||||
use nu_protocol::{util::BufferedReader, PipelineData, RawStream};
|
use nu_protocol::{util::BufferedReader, PipelineData, RawStream};
|
||||||
use signals::{ctrlc_protection, sigquit_protection};
|
use signals::{ctrlc_protection, sigquit_protection};
|
||||||
use std::str::FromStr;
|
|
||||||
use std::{
|
use std::{
|
||||||
io::BufReader,
|
io::BufReader,
|
||||||
|
str::FromStr,
|
||||||
sync::{atomic::AtomicBool, Arc},
|
sync::{atomic::AtomicBool, Arc},
|
||||||
|
time::Instant,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
|
let start_time = Instant::now();
|
||||||
let miette_hook = std::panic::take_hook();
|
let miette_hook = std::panic::take_hook();
|
||||||
std::panic::set_hook(Box::new(move |x| {
|
std::panic::set_hook(Box::new(move |x| {
|
||||||
crossterm::terminal::disable_raw_mode().expect("unable to disable raw mode");
|
crossterm::terminal::disable_raw_mode().expect("unable to disable raw mode");
|
||||||
|
@ -316,6 +318,7 @@ fn main() -> Result<()> {
|
||||||
&mut stack,
|
&mut stack,
|
||||||
config_files::NUSHELL_FOLDER,
|
config_files::NUSHELL_FOLDER,
|
||||||
parsed_nu_cli_args.execute,
|
parsed_nu_cli_args.execute,
|
||||||
|
start_time,
|
||||||
);
|
);
|
||||||
info!("repl eval {}:{}:{}", file!(), line!(), column!());
|
info!("repl eval {}:{}:{}", file!(), line!(), column!());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue