nushell/crates/nu-command/src
132ikl 3a1601de8e
Add flag to debug profile to output duration field as Value::Duration (#14749)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->

This PR adds a flag to `debug profile` to output the duration field as
Value::Duration. Without the flag, the behavior is same as before: a
column named `duration_ms` which is `Value::Float`. With the flag, there
is instead a column named just `duration` which is `Value::Duration`.
Additionally, this PR changes the time tracking to use nanoseconds
instead of float seconds, so it can be output as either milliseconds or
`Duration` (which uses nanoseconds internally). I don't think overflow
is a concern here, because the maximum amount of time a `Duration` can
store is over 292 years, and if a Nushell instruction takes longer than
that to run then I think we might have bigger issues.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

* Adds a flag `--duration-values` to `debug profile` which the
`duration_ms` field in `debug profile` to a `duration` field which uses
proper `duration` values.

# 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` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` to run the
tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# 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.
-->
N/A
2025-01-09 17:09:16 -06:00
..
bytes Add bytes split command (#14652) 2024-12-25 07:04:43 -06:00
charting Add Filesize type (#14369) 2024-11-29 21:24:17 +00:00
conversions Add run-time type checking for command pipeline input (#14741) 2025-01-08 23:09:47 +01:00
database Remove usages of internal_span (#14700) 2024-12-30 16:47:06 +08:00
date Remove deprecated commands (#14726) 2025-01-07 07:37:51 +08:00
debug Add flag to debug profile to output duration field as Value::Duration (#14749) 2025-01-09 17:09:16 -06:00
env Enable conditional source and use patterns by allowing null as a no-op module (#14773) 2025-01-09 06:37:27 -06:00
experimental Start to Add WASM Support Again (#14418) 2024-11-30 07:57:11 -06:00
filesystem Handle permission denied error at nu_engine::glob_from (#14679) 2025-01-07 15:44:55 -06:00
filters Add run-time type checking for command pipeline input (#14741) 2025-01-08 23:09:47 +01:00
formats Add run-time type checking for command pipeline input (#14741) 2025-01-08 23:09:47 +01:00
generators Bump typos workflow to 1.29.4 (#14782) 2025-01-08 15:11:47 +01:00
hash
help replace regex crate with fancy_regex (#14646) 2025-01-01 17:37:50 -06:00
math better error message for "sum", "product", and "sum_of_squares" (#14711) 2024-12-31 16:04:23 -06:00
misc Enable conditional source and use patterns by allowing null as a no-op module (#14773) 2025-01-09 06:37:27 -06:00
network more closure serialization (#14698) 2025-01-07 11:51:22 -06:00
path Add path self command for getting absolute paths to files at parse time (#14303) 2024-12-06 08:19:08 -06:00
platform Remove usages of internal_span (#14700) 2024-12-30 16:47:06 +08:00
random Add Filesize type (#14369) 2024-11-29 21:24:17 +00:00
removed
shells
stor fix stor reset when there are foreign keys (#14772) 2025-01-07 10:28:26 -06:00
strings replace regex crate with fancy_regex (#14646) 2025-01-01 17:37:50 -06:00
system Add run-time type checking for command pipeline input (#14741) 2025-01-08 23:09:47 +01:00
viewers expand custom values on table display (#14760) 2025-01-06 18:09:55 -06:00
default_context.rs Remove deprecated commands (#14726) 2025-01-07 07:37:51 +08:00
example_test.rs
lib.rs Start to Add WASM Support Again (#14418) 2024-11-30 07:57:11 -06:00
progress_bar.rs
sort_utils.rs Remove deprecated commands (#14726) 2025-01-07 07:37:51 +08:00