Skip to content

Instantly share code, notes, and snippets.

@bohanyang
Last active May 13, 2024 04:49
Show Gist options
  • Save bohanyang/652c917fc771360babe601b874bcd22f to your computer and use it in GitHub Desktop.
Save bohanyang/652c917fc771360babe601b874bcd22f to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
set -ex
command_exists() {
command -v "$@" > /dev/null 2>&1
}
user="$(id -un 2>/dev/null || true)"
sudo=''
if [ "$user" != 'root' ]; then
if command_exists sudo; then
sudo='sudo'
else
exit 1
fi
fi
if ! command_exists sysbench; then
$sudo bash -c "$(wget -qO- https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh)"
$sudo apt install -y --no-install-recommends sysbench
fi
cat /proc/cpuinfo > sysbench.log
sysbench cpu run | tee -a sysbench.log
core_n="$(nproc --all)"
if [ "$core_n" -gt 1 ]; then
sysbench --threads="$core_n" cpu run | tee -a sysbench.log
fi
sysbench --memory-oper=read --memory-access-mode=rnd memory run | tee -a sysbench.log
sysbench --memory-oper=write --memory-access-mode=rnd memory run | tee -a sysbench.log
sysbench --memory-oper=read --memory-access-mode=seq memory run | tee -a sysbench.log
sysbench --memory-oper=write --memory-access-mode=seq memory run | tee -a sysbench.log
sysbench fileio prepare
sysbench --file-test-mode=seqrd fileio run | tee -a sysbench.log
sysbench --file-test-mode=seqwr fileio run | tee -a sysbench.log
sysbench fileio cleanup
sysbench fileio prepare
sysbench --file-test-mode=rndrd fileio run | tee -a sysbench.log
sysbench --file-test-mode=rndwr fileio run | tee -a sysbench.log
sysbench fileio cleanup
sysbench fileio prepare
sysbench --file-test-mode=rndrw fileio run | tee -a sysbench.log
sysbench fileio cleanup
@bohanyang
Copy link
Author

bohanyang commented Dec 2, 2018

sh -c "$(wget -qO- https://git.io/fjnHd)"

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