benchmark 툴에서 실험 결과에 들어갈 정보를 주지 않을 때, dstat에 찍히는 bandwidth를 측정해주는 스크립트이다.
#!/bin/bash
SESSION_NAME="<session_name>"
compare_version="<kernel_version>"
kernel_version=$(uname -r)
result_path="dstat"
file_name="<result_filename>"
generate_unique_filename() {
local base_name="$1"
local extension="csv"
local count=1
local new_filename="${result_path}/${base_name}_${count}.${extension}"
while [ -e "$new_filename" ]; do
count=$((count + 1))
new_filename="${result_path}/${base_name}_${count}.${extension}"
done
echo $new_filename
}
if [[ "$kernel_version" == *"$compare_version"* ]]; then
result_path+="/proposed"
else
result_path+="/original"
fi
mkdir -p ${result_path}
unique_filename=$(generate_unique_filename $file_name)
echo $unique_filename
cur_path=$(pwd)
tmux new-session -d -s $SESSION_NAME "dstat --output ${cur_path}/${unique_filename}"
# test code
# do something
sleep 2
tmux send-keys -t $SESSION_NAME C-c
sleep 1
tmux kill-session -t $SESSION_NAME # 혹시 모르니 한번 더 종료