A place to share Nushell scripts with each other
Go to file
Maxim Uvarov 308d858c4f
simplify the std bench improvement candidate (#865)
@amtoine gave me valuable feedback about the [PR of `std bench`
improvement](https://github.com/nushell/nu_scripts/pull/859) CANDIDATE
into `stdlib-candidates`.

I understood and respected his reasoning about his position. Yet, I
still believe that users of `std bench` will benefit from my proposal.

I incorporated some of @amtoine advice in this PR.

I removed the `bench --units` option as I now believe it is better to
encourage users to use core functionality for formatting duration (which
I had not thought of initially) and to avoid multiplying `--options`.

```
bench -n 10 {sleep 0.1sec} | format duration ms mean min max stddev
# or
bench -n 10 {sleep 0.1sec} | format duration ms ...($in | columns)
```

Also, I removed the option of `--sign-digits` and just hard-coded the
precision of conversion to the fourth significant digit (which will give
a maximum relative error of 0.05%, which I still think is unnecessarily
precise).

To explain my motivation, I added some context from our previous
conversation:

>> Maybe you would agree with me that this representation is very wordy
and unnecessary, even for a professional?
>> `1sec 333ms 333µs 333ns`

> maybe, but then i would argue the issue comes from the formatting
nushell does on durations, not from std bench, it's just that Nushell
will show every part of the duration 😕

And I add here that if Nushell adds the setting for resetting
insignificant digits from displaying, those conversions could be removed
for the better. Yet, we don't have such a setting yet, but we already
use bench and use it quite often. So, I propose this usability
improvement.

In my defense, I would add that the existing `--pretty` option will only
benefit from the proposed changes (while it can't benefit from `| format
duration ms`).

```diff
> bench {sleep (10sec / 3)} --rounds 2 --pretty
- 3sec 335ms 974µs 264ns +/- 1ms 108µs 748ns
+ 3sec 335ms +/- 1ms 108µs
```

Finally, I kept the `--list-timings` option because I strongly believe
that users much more often will not need expanded 50 lines of timing
results on their screen (which they can get rid of by adding `| reject
time` in the second execution of the `bench` command - but I would like
to avoid this second execution).

I won't be hurt if my proposed changes aren't accepted and applied to
mainstream. Yet, I feel like my initial PR is still valuable and will
benefit from my current PR's additions.
2024-06-03 08:35:33 -05:00
.github/workflows features = full isn't a thing anymore 2024-06-01 04:41:31 -05:00
aliases feat: add docker aliases (#861) 2024-06-03 06:38:38 -05:00
assets use typos for corrections (#833) 2024-05-08 06:47:54 -05:00
before_v0.60/cool_oneliners Port before_v0.60/with_externals and cleanup (#852) 2024-05-26 16:34:36 -05:00
benchmarks fix removed commands (#645) 2023-10-19 19:35:23 +02:00
custom-completions Support whitespace before target name for make completions (#858) 2024-05-30 14:37:43 -05:00
custom-menus fix: adjust for nushell commandline syntax deprecation (#840) 2024-05-19 13:33:08 -05:00
example-config use typos for corrections (#833) 2024-05-08 06:47:54 -05:00
make_release Edit release notes template (#853) 2024-05-28 19:32:39 +00:00
modules Port before_v0.60/with_externals and cleanup (#852) 2024-05-26 16:34:36 -05:00
nu-hooks use typos for corrections (#833) 2024-05-08 06:47:54 -05:00
sourced Port before_v0.60/data_extraction before_v0.60/examples before_v0.60/duplicates (#847) 2024-05-26 12:37:29 -05:00
stdlib-candidate simplify the std bench improvement candidate (#865) 2024-06-03 08:35:33 -05:00
themes fix: adjust for nushell commandline syntax deprecation (#840) 2024-05-19 13:33:08 -05:00
.gitattributes Add Nushell Language detect for linguist (#532) 2023-06-21 11:36:01 +03:00
.gitignore fix regressions noted in 0.93.1 from 0.83: (#843) 2024-05-25 08:28:42 -05:00
LICENSE Initial commit 2021-01-23 07:33:45 +13:00
README.md Remove the failing CI on the main branch (#805) 2024-03-30 16:37:19 -05:00
toolkit.nu Refactor toolkit.nu (#791) 2024-03-15 19:17:31 +02:00
typos.toml use typos for corrections (#833) 2024-05-08 06:47:54 -05:00

Nushell Scripts

This is a place to share Nushell scripts with each other. If you'd like to share your scripts, fork this repository, and create a PR that adds it to the repo.

Sections

Running Scripts

You can run nushell scripts in a few different ways.

  1. You can type nu <script name>.
  2. From with nushell, you can type source <script name> and if the script is just a bunch of commands it will run the script. If the script is a custom command it will load those custom commands into your current scope so you can run them like any other command.