Skip to content

Instantly share code, notes, and snippets.

@tueda
Created August 22, 2025 06:46
Show Gist options
  • Select an option

  • Save tueda/664d5dda26de48c7c338864c0b1ce090 to your computer and use it in GitHub Desktop.

Select an option

Save tueda/664d5dda26de48c7c338864c0b1ce090 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# @file openssl-bench.sh
#
# Runs an OpenSSL SHA-256 benchmark and prints the time (in seconds)
# to process 1 terabyte.
#
# Usage:
# openssl-bench.sh [NUM_CPUS]
#
set -euo pipefail
ncpu="${1:-1}"
if [[ "$ncpu" -eq 1 ]]; then
opts=
else
opts="-multi $ncpu"
fi
bytes_per_second=$(
openssl speed -evp sha256 -bytes 16384 -seconds 10 -mr $opts 2>/dev/null \
| grep '^+F' | tail -1 | awk -F: '{print $NF}'
)
time_per_tb=$(echo "10^12 / $bytes_per_second" | bc -l)
echo "$time_per_tb"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment