nu_scripts/stdlib-candidate/std-rfc
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
..
math hotfix for significant-digits to not error if the input was 0 (#863) 2024-06-03 08:33:34 -05:00
record Refactor stdlib-candidate for nupm (#790) 2024-03-16 13:57:05 +02:00
str Clean up str append/prepend a little (#797) 2024-03-20 10:46:12 -05:00
bench.nu simplify the std bench improvement candidate (#865) 2024-06-03 08:35:33 -05:00
bulk-rename.nu [stdlib-candidate] Clean up file bulk-rename a little (#798) 2024-03-30 16:19:06 -05:00
flatter.nu Port before_v0.60/stdlib_candidate (#850) 2024-05-26 07:49:03 -05:00
get-column.nu Port before_v0.60/stdlib_candidate (#850) 2024-05-26 07:49:03 -05:00
get-latest-release-linux.nu Port before_v0.60/stdlib_candidate (#850) 2024-05-26 07:49:03 -05:00
get-row.nu Port before_v0.60/stdlib_candidate (#850) 2024-05-26 07:49:03 -05:00
logging.nu Port before_v0.60/stdlib_candidate (#850) 2024-05-26 07:49:03 -05:00
mod.nu improve std bench and add significant-digits (#859) 2024-06-01 04:54:45 -05:00
nu_style.nu Port before_v0.60/stdlib_candidate (#850) 2024-05-26 07:49:03 -05:00
print.nu Port before_v0.60/stdlib_candidate (#850) 2024-05-26 07:49:03 -05:00
set-env.nu Clean up str append/prepend a little (#797) 2024-03-20 10:46:12 -05:00