by clarkmoody · 6y ago · 0 comments
time openssl sha256 /tmp/bigfile
real 0m28.160s
user 0m27.750s
sys 0m0.272s
time shasum -a 256 /tmp/bigfile real 0m6.146s
user 0m5.407s
sys 0m0.560s
time b2sum /tmp/bigfile real 0m1.732s
user 0m1.450s
sys 0m0.244s
time b3sum /tmp/bigfile real 0m0.212s
user 0m0.996s
sys 0m0.379s
TIL OpenSSL sha256 invocation is really slow compared to the shasum program. Also BLAKE3 is really fast.Edit: bigfile is 1GB of /dev/random
b3sum ./1GB 0m0.124s
md5sum ./1GB 0m1.620s
sha512sum ./1GB 0m2.988s
sha256sum ./1GB 0m4.738s
I was even more impressed when I timed dd: $ time dd if=./1GB of=/dev/null bs=65536
16384+0 records in
16384+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.10451 s, 10.3 GB/s
real 0m0.107ssha256sum uses 128KiB blocks when reading, which may be more optimized than the openssl program.
sha256sum supports using openssl libs as they are generally faster. This is enabled on Red Hat flavored distros and arch, but not debian flavored as yet
The upcoming release of sha256sum (8.32) will auto enable use of openssl for >= v 3, as openssl's licence has changed to apache in that version