Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libc: Use a byte slice for strftime format
Converting the strftime format Rust string slice into a C-compatible string takes CPU cycles that can be avoided by using a byte slice instead. Once c"…" string literals are stable, use those. Benchmark results on a Raspberry Pi Zero 2W running Ubuntu 24.04 (noble) arm64: ``` $ sudo 3cpio -x /boot/initrd.img -C /var/tmp/initrd $ ( cd /var/tmp/initrd && find . | LC_ALL=C sort | sudo cpio --reproducible --quiet -o -H newc ) > initrd.img $ hyperfine -N --warmup 3 --runs 100 "target/release/3cpio -tv initrd.img" "3cpio-0.3.0+8 -tv initrd.img" Benchmark 1: target/release/3cpio -tv initrd.img Time (mean ± σ): 113.2 ms ± 1.1 ms [User: 50.6 ms, System: 61.3 ms] Range (min … max): 111.2 ms … 116.6 ms 100 runs Benchmark 2: 3cpio-0.3.0+8 -tv initrd.img Time (mean ± σ): 115.1 ms ± 1.0 ms [User: 52.6 ms, System: 61.2 ms] Range (min … max): 113.1 ms … 118.5 ms 100 runs Summary target/release/3cpio -tv initrd.img ran 1.02 ± 0.01 times faster than 3cpio-0.3.0+8 -tv initrd.img ```
- Loading branch information