-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
Description
In seq
, we found that directly calling stdout.write_all(str.as_bytes())?
is quite a bit faster than using format to do the same operation: write!(stdout, "{str}")?
. #7562
ls
uses a lot of write!(..., "{}", ..)?;
patterns. Would be nice to know if switching to write_all
would improve performance.
Had a very quick look at samply
output, and printing dominate more of the runtime in long format outputs (e.g. ls -l
), so maybe it'd be good to start investigating that use case.
For reference, we're doing a bit worse than coreutils:
$ cargo build -r -p uu_ls && taskset -c 0 hyperfine --warmup 3 -L ls target/release/ls,ls "{ls} -lR .git"
Finished `release` profile [optimized] target(s) in 0.12s
Benchmark 1: target/release/ls -lR .git
Time (mean ± σ): 32.5 ms ± 0.8 ms [User: 18.7 ms, System: 13.5 ms]
Range (min … max): 31.2 ms … 34.4 ms 84 runs
Benchmark 2: ls -lR .git
Time (mean ± σ): 23.7 ms ± 1.5 ms [User: 11.3 ms, System: 12.0 ms]
Range (min … max): 23.0 ms … 38.6 ms 114 runs
Summary
ls -lR .git ran
1.37 ± 0.10 times faster than target/release/ls -lR .git