Skip to content

Instantly share code, notes, and snippets.

@tdebatty
Last active July 7, 2024 11:20
Show Gist options
  • Save tdebatty/0358da0a2068eca1bf4583a06aa0acf2 to your computer and use it in GitHub Desktop.
Save tdebatty/0358da0a2068eca1bf4583a06aa0acf2 to your computer and use it in GitHub Desktop.
sysbench wrapper
#!/bin/bash
#
# bench.sh
# https://gist.github.com/tdebatty/0358da0a2068eca1bf4583a06aa0acf2
#
# https://cylab.be/blog/351/performance-of-virtual-storage-part-2-qemu
#
# a wrapper for sysbench
# quick run:
# bash <(curl -Ls https://gist.githubusercontent.com/tdebatty/0358da0a2068eca1bf4583a06aa0acf2/raw/bench.sh)
#
echo "
███████╗██╗ ██╗███████╗██████╗ ███████╗███╗ ██╗ ██████╗██╗ ██╗
██╔════╝╚██╗ ██╔╝██╔════╝██╔══██╗██╔════╝████╗ ██║██╔════╝██║ ██║
███████╗ ╚████╔╝ ███████╗██████╔╝█████╗ ██╔██╗ ██║██║ ███████║
╚════██║ ╚██╔╝ ╚════██║██╔══██╗██╔══╝ ██║╚██╗██║██║ ██╔══██║
███████║ ██║ ███████║██████╔╝███████╗██║ ╚████║╚██████╗██║ ██║
╚══════╝ ╚═╝ ╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝╚═╝ ╚═╝
"
echo "check if sysbench is installed ..."
command -v sysbench >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "sysbench not found, installing ..."
sudo apt update -qq
sudo apt install -y -qq sysbench
fi
echo "CPU : single core"
echo "================="
sysbench cpu run | grep -oP 'events per second:\s+(\d+)'
echo "CPU : multi core"
echo "================"
CORES=$(grep -c processor /proc/cpuinfo)
echo "$CORES cores"
sysbench cpu run --threads="$CORES" | grep -oP 'events per second:\s+(\d+)'
echo "Memory"
echo "======"
sysbench memory run | grep -oP '(\d+\.\d+) MiB\/sec'
echo "Storage"
echo "======="
echo "prepare data ..."
sysbench fileio --file-total-size=5G --file-num=5 --verbosity=0 prepare
echo "random access ..."
sysbench fileio --file-total-size=5G --file-num=5 --file-io-mode=async --file-fsync-freq=0 --file-test-mode=rndrd --file-block-size=4k run | grep -oP 'read, MiB/s:\s+(\d+)'
sysbench fileio --file-total-size=5G --file-num=5 --file-io-mode=async --file-fsync-freq=0 --file-test-mode=rndwr --file-block-size=4k run | grep -oP 'written, MiB/s:\s+(\d+)'
echo "sequential access ..."
sysbench fileio --file-total-size=5G --file-num=5 --file-io-mode=async --file-fsync-freq=0 --file-test-mode=seqrd --file-block-size=1M run | grep -oP 'read, MiB/s:\s+(\d+)'
sysbench fileio --file-total-size=5G --file-num=5 --file-io-mode=async --file-fsync-freq=0 --file-test-mode=seqwr --file-block-size=1M run | grep -oP 'written, MiB/s:\s+(\d+)'
echo "cleanup ..."
rm test_file.*
@tdebatty
Copy link
Author

tdebatty commented Jul 6, 2024

A simple wrapper for sysbench. I use it to quickly benchmark Linux computers and servers.

bash <(curl -Ls https://gist.githubusercontent.com/tdebatty/0358da0a2068eca1bf4583a06aa0acf2/raw/bench.sh)

scaleway-block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment