mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
feat(sum): use larger buffer in bsd_sum and sysv_sum
This commit is contained in:
committed by
Daniel Hofstetter
parent
83b09a4b6b
commit
471c68dae9
@@ -13,11 +13,11 @@ cargo build --release --package uu_sum
|
||||
and then you can time how it long it takes to checksum the file by running
|
||||
|
||||
```shell
|
||||
time ./target/release/sum wikidatawiki-20211001-pages-logging.xml
|
||||
time ./target/release/sum wikidatawiki-20251220-pages-logging.xml
|
||||
```
|
||||
|
||||
For more systematic measurements that include warm-ups, repetitions and comparisons, [Hyperfine](https://github.com/sharkdp/hyperfine) can be helpful. For example, to compare this implementation to the one provided by your distribution run
|
||||
|
||||
```shell
|
||||
hyperfine "./target/release/sum wikidatawiki-20211001-pages-logging.xml" "sum wikidatawiki-20211001-pages-logging.xml"
|
||||
hyperfine "./target/release/sum wikidatawiki-20251220-pages-logging.xml" "sum wikidatawiki-20251220-pages-logging.xml"
|
||||
```
|
||||
|
||||
@@ -16,8 +16,11 @@ use uucore::translate;
|
||||
|
||||
use uucore::{format_usage, show};
|
||||
|
||||
// Fixed to 8 KiB (equivalent to `std::sys::io::DEFAULT_BUF_SIZE` on most targets)
|
||||
const DEFAULT_BUF_SIZE: usize = 8 * 1024;
|
||||
|
||||
fn bsd_sum(mut reader: impl Read) -> std::io::Result<(usize, u16)> {
|
||||
let mut buf = [0; 4096];
|
||||
let mut buf = [0; DEFAULT_BUF_SIZE];
|
||||
let mut bytes_read = 0;
|
||||
let mut checksum: u16 = 0;
|
||||
loop {
|
||||
@@ -41,7 +44,7 @@ fn bsd_sum(mut reader: impl Read) -> std::io::Result<(usize, u16)> {
|
||||
}
|
||||
|
||||
fn sysv_sum(mut reader: impl Read) -> std::io::Result<(usize, u16)> {
|
||||
let mut buf = [0; 4096];
|
||||
let mut buf = [0; DEFAULT_BUF_SIZE];
|
||||
let mut bytes_read = 0;
|
||||
let mut ret = 0u32;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user