#! /bin/sh # Global variables SYSTEM=`uname -sr` THREADING_LIB="libc_r" # Values: libc_r / libthread_xu WAIT_TIME=50 USER_ID=`id -u` LOGS_PATH="" # paths to utilities SYSBENCH_PATH="" MYSQL_PATH="" # Test for dragonfly OS test_dragonfly() { SYST=`uname -s` if [ $SYST = "DragonFly" ]; then echo I have detected that you are using a DragonFly BSD system. echo Now I will change threading library to use $THREADING_LIB echo echo else return fi # Delete old symbolic link [ -s "/usr/lib/libpthread.so.0" ] && rm -f /usr/lib/libpthread.so.0 case $THREADING_LIB in libc_r) ln -s /usr/lib/libc_r.so /usr/lib/libpthread.so.0 ;; libthread_xu) ln -s /usr/lib/libthread_xu.so /usr/lib/libpthread.so.0 ;; default) echo Wrong value on THREADING_LIB var inside this script. Falling back to libc_r ln -s /usr/lib/libc_r.so /usr/lib/libpthread.so.0 ;; esac # Set the path for log LOGS_PATH="/root/bench_logs/$THREADING_LIB" } # Test user permissions test_root() { if [ $USER_ID -ne 0 ]; then echo Sorry, you need to be root in order to run this script exit fi } # Test whether tools are present in the system test_tools() { EXIST=0 PATH_TO=`/usr/bin/which sysbench` # Let's search for sysbench if [ "$PATH_TO" != "" ]; then SYSBENCH_PATH=$PATH_TO EXIST=1 else # Test sysbench utility in common paths [ -s "/usr/local/sysbench/bin/sysbench" ] && EXIST=1 && SYSBENCH_PATH="/usr/local/sysbench/bin/sysbench" [ -s "/usr/bin/sysbench" ] && EXIST=1 && SYSBENCH_PATH="/usr/bin/sysbench" [ -s "/usr/local/bin/sysbench" ] && EXIST=1 && SYSBENCH_PATH="/usr/local/bin/sysbench" fi if [ $EXIST -eq 0 ]; then echo sysbench utility is neither in your path or installed in your system exit else echo Found sysbench tool on: $SYSBENCH_PATH fi # Let's search for mysql client EXIST=0 PATH_TO=`/usr/bin/which mysql` if [ "$PATH_TO" != "" ]; then MYSQL_PATH=$PATH_TO EXIST=1 else # Test sysbench utility in common paths [ -s "/usr/local/mysql/bin/mysql" ] && EXIST=1 && MYSQL_PATH="/usr/local/mysql/bin/mysql" [ -s "/usr/bin/mysql" ] && EXIST=1 && MYSQL_PATH="/usr/bin/mysql" [ -s "/usr/local/bin/mysql" ] && EXIST=1 && MYSQL_PATH="/usr/local/bin/mysql" fi if [ $EXIST -eq 0 ]; then echo mysql client utility is neither in your path or installed in your system exit else echo Found mysql client tool on: $MYSQL_PATH fi } # global enviroment setup_global() { [ "$LOGS_PATH" = "" ] && LOGS_PATH="/root/bench_logs/logs" [ ! -s $LOGS_PATH ] && mkdir -p $LOGS_PATH echo echo I will store log files in $LOGS_PATH. If path does not exist I will create it. } # File IO benchs bench_fileio() { for i in 1 2 3 4 5 6 7 8; do echo "Running File I/O benchmarks. Using $i thread(s)" $SYSBENCH_PATH --test=fileio run --file-test-mode=seqwr --num-threads=$i > $LOGS_PATH/fileio_seqwr_t$i.log $SYSBENCH_PATH --test=fileio run --file-test-mode=seqrewr --num-threads=$i > $LOGS_PATH/fileio_seqrewr_t$i.log $SYSBENCH_PATH --test=fileio run --file-test-mode=seqrd --num-threads=$i > $LOGS_PATH/fileio_seqrd_t$i.log $SYSBENCH_PATH --test=fileio run --file-test-mode=rndrd --num-threads=$i > $LOGS_PATH/fileio_rndrd_t$i.log $SYSBENCH_PATH --test=fileio run --file-test-mode=rndwr --num-threads=$i > $LOGS_PATH/fileio_rndwr_t$i.log $SYSBENCH_PATH --test=fileio run --file-test-mode=rndrw --num-threads=$i > $LOGS_PATH/fileio_rndrw_t$i.log done } # CPU benchs bench_cpu() { for i in 1 2 3 4 5 6 7 8; do echo "Running CPU benchmarks. Using $i thread(s)" $SYSBENCH_PATH --test=cpu run --num-threads=$i > $LOGS_PATH/cpu_t$i.log done } # memory bench bench_mem() { for i in 1 2 3 4 5 6 7 8; do echo "Running Memory benchmarks. Using $i thread(s)" $SYSBENCH_PATH --test=memory run --num-threads=$i --memory-scope=local --memory-oper=read --memory-access-mode=seq > $LOGS_PATH/mem_local_seq_read_t$i.log $SYSBENCH_PATH --test=memory run --num-threads=$i --memory-scope=local --memory-oper=read --memory-access-mode=rnd > $LOGS_PATH/mem_local_rnd_read_t$i.log $SYSBENCH_PATH --test=memory run --num-threads=$i --memory-scope=global --memory-oper=read --memory-access-mode=seq > $LOGS_PATH/mem_global_seq_read_t$i.log $SYSBENCH_PATH --test=memory run --num-threads=$i --memory-scope=global --memory-oper=read --memory-access-mode=rnd > $LOGS_PATH/mem_global_rnd_read_t$i.log $SYSBENCH_PATH --test=memory run --num-threads=$i --memory-scope=local --memory-oper=write --memory-access-mode=seq > $LOGS_PATH/mem_local_seq_write_t$i.log $SYSBENCH_PATH --test=memory run --num-threads=$i --memory-scope=local --memory-oper=write --memory-access-mode=rnd > $LOGS_PATH/mem_local_rnd_write_t$i.log $SYSBENCH_PATH --test=memory run --num-threads=$i --memory-scope=global --memory-oper=write --memory-access-mode=seq > $LOGS_PATH/mem_global_seq_write_t$i.log $SYSBENCH_PATH --test=memory run --num-threads=$i --memory-scope=global --memory-oper=write --memory-access-mode=rnd > $LOGS_PATH/mem_global_rnd_write_t$i.log done } # threads benchs bench_threads() { for i in 1 2 3 4 5 6 7 8; do echo "Running Threads benchmarks. Using $i thread(s)" $SYSBENCH_PATH --test=threads run --num-threads=$i > $LOGS_PATH/threads_t$i.log done } #mutexes benchs bench_mutex() { for i in 1 2 3 4 5 6 7 8; do echo "Running mutexes benchmarks. Using $i thread(s)" $SYSBENCH_PATH --test=mutex run --num-threads=$i > $LOGS_PATH/mutex_t$i.log done } # oltp bench bench_oltp() { for i in 1 2 3 4 5 6 7 8; do echo "Running OLTP benchmarks. Using $i thread(s)" $SYSBENCH_PATH --test=oltp run --mysql-host=localhost --mysql-user=root --mysql-password=test123 --num-threads=$i > $LOGS_PATH/oltp_t$i.log done } # Start!! echo echo This script will run 144 test with sysbench utility echo Running on $SYSTEM echo # Initialization test_dragonfly test_root test_tools setup_global # Running benchmarks bench_fileio bench_cpu bench_mem bench_threads bench_mutex bench_oltp