In most common use cases:
- We can bypass a lot of `write_output` when width == 0.
- Simplify format_float_decimal when the input is an integer.
Also document another interesting case in src/uu/seq/BENCHMARKING.md.
Display hexadecimal floats with arbitrary precision.
Note that some of the logic will produce extremely large
BitInt as intermediate values: there is some optimization
possible here, but the current implementation appears to work
fine for reasonable numbers (e.g. whatever would previously
fit in a f64, and even with somewhat large precision).
No more f64 operations needed, we just trim (or extend) BigDecimal to
appropriate precision, get the digits as a string, then add the
decimal point.
Similar to what BigDecimal::write_scientific_notation does, but
we need a little bit more control.
Using an associated type in Formatter trait was quite nice, but, in
a follow-up change, we'd like to pass a _reference_ to the Float
Formatter, while just passing i64/u64 as a value to the Int
formatters. Associated type doesn't allow for that, so we turn
it into a generic instead.
This makes Format<> a bit more complicated though, as we need
to specify both the Formatter, _and_ the type to be formatted.
Will make it possible to directly print ExtendedBigDecimal in `seq`,
and gradually get rid of limited f64 precision in other tools
(e.g. `printf`).
Changes are mostly mechanical, we reexport ExtendedBigDecimal directly
in format to keep the imports slightly shorter.
* Add test to ensure arch output is not empty
This test ensures that the output of the arch command is non-empty, which is a minimal expectation across all supported architectures.
This helps avoid regressions or edge cases where the command might unexpectedly return an empty string on unsupported or misconfigured platforms.
* Update tests/by-util/test_arch.rs
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* Apply cargo fmt formatting
---------
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
Issue #7494
Improve performace of wc app.
- Use the bytecount::num_chars API to count UTF-8 characters in a file.
- Enable runtime-dispatch-simd feature in the bytecount crate.
Use a BufWriter to wrap stdout: reduces the numbers of system calls,
improves performance drastically (2x in some cases).
Also document use cases in src/uu/seq/BENCHMARKING.md, and the
optimization we have just done here.
* GNU/CI: use the aggregated-result.json files and move to python
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* simplify code
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
---------
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>