Companion repository to this post on my blog.
Scripts to benchmark the several cryptographic hash functions using the
OpenSSL speed
command and generate SVGs of the results.
The hash functions are as follows:
You'll need Bundler and pipenv installed.
- Download the OpenSSL source code.
- Compile OpenSSL from source (
./Configure && make
). - Run
bundle install --without=dev
to install the Ruby dependencies. - Run
pipenv sync
to install the Python dependencies. - (Optional) Install minify.
sudo apt install minify
. Instructions for other platforms are available here.
Example:
# install ruby dependencies
bundle install --without=dev
# install python dependencies
pipenv sync
# install minify (debian)
sudo apt install minify
- Set
LD_LIBRARY_PATH
to the OpenSSL source directory. - Prepend
SSL_DIR/apps
toPATH
. - Verify that you are using the version of OpenSSL compiled
in the installation instructions above using the
openssl version
command. - Run
bundle exec bin/bench.rb > results.json
to run the hash write the JSON-formatted results to./results.json
. - Run
pipenv run bin/plot.py < ./results.json > results.svg
. - (Optional) Minify the SVG:
minify results.svg > results.min.svg
.
Example:
# set LD_LIBRARY_PATH and PATH
SSL_DIR=$HOME/src/openssl-3.0.3
export LD_LIBRARY_PATH="$SSL_DIR" PATH="$SSL_DIR/apps:$PATH"
# run benchmarks, write results to results.json
bundle exec bin/bench.rb > results.json
# generate SVG
pipenv run bin/plot.py < results.json > results.svg
# write minified SVG to results.min.svg
minify results.svg > results.min.svg
Shorter version:
# set LD_LIBRARY_PATH and PATH
SSL_DIR=$HOME/src/openssl-3.0.3
export LD_LIBRARY_PATH="$SSL_DIR" PATH="$SSL_DIR/apps:$PATH"
# run benchmarks and write SVG to "results.min.svg"
bundle exec bin/bench.rb | \
pipenv run bin/plot.py | \
minify --type svg > results.min.svg
Example results:
Repository contents: