Skip to content

Instantly share code, notes, and snippets.

@elena-kolevska
Last active December 23, 2019 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elena-kolevska/3265afb4115387838d70614c1d570211 to your computer and use it in GitHub Desktop.
Save elena-kolevska/3265afb4115387838d70614c1d570211 to your computer and use it in GitHub Desktop.
Small cli tool for setting up parameters of the memtier_benchmark tool
#!/usr/bin/env bash
# Colours definition
HIGHLIGHT1='\033[0;34m'
HIGHLIGHT2='\033[0;33m'
SUCCESS='\033[0;32m'
ERROR='\033[0;31m'
GRAY='\033[0;37m'
NC='\033[0m' # No Color
echo "======================"
printf "${HIGHLIGHT1}What's the memtier_benchmark executable path?${NC}\n"
printf "(Default is memtier_benchmark)"
printf "${HIGHLIGHT1}>>>${NC}"
read PATH
if [ "$PATH" == "" ];
then
PATH="memtier_benchmark"
fi
printf "${HIGHLIGHT1}Which host should I connect to?${NC}\n"
printf "(Default is 127.0.0.1)"
printf "${HIGHLIGHT1}>>>${NC}"
read HOST
if [ "$HOST" == "" ];
then
HOST="127.0.0.1"
fi
printf "${HIGHLIGHT1}And which port?${NC}\n"
printf "(Default is 6379)"
printf "${HIGHLIGHT1}>>>${NC}"
read PORT
if [ "$PORT" == "" ];
then
PORT="6379"
fi
printf "${HIGHLIGHT1}How many threads should I use?${NC}\n"
printf "(Default is 4)"
printf "${HIGHLIGHT1}>>>${NC}"
read NUM_THREADS
if [ "$NUM_THREADS" == "" ];
then
NUM_THREADS="4"
fi
printf "${HIGHLIGHT1}How many clients per thread?${NC}\n"
printf "(Default is 5)"
printf "${HIGHLIGHT1}>>>${NC}"
read NUM_CLIENTS
if [ "$NUM_CLIENTS" == "" ];
then
NUM_CLIENTS="5"
fi
printf "${HIGHLIGHT1}How many concurrent pipelined requests?${NC}\n"
printf "(Default is 30)"
printf "${HIGHLIGHT1}>>>${NC}"
read NUM_PIPELINES
if [ "$NUM_PIPELINES" == "" ];
then
NUM_PIPELINES="30"
fi
printf "${HIGHLIGHT1}Set:Get ratio?${NC}\n"
printf "(Default is 1:1)"
printf "${HIGHLIGHT1}>>>${NC}"
read RATIO
if [ "$RATIO" == "" ];
then
RATIO="1:1"
fi
printf "${HIGHLIGHT1}Message size?${NC}\n"
printf "(Default is 150)"
printf "${HIGHLIGHT1}>>>${NC}"
read MESSAGE_SIZE
if [ "$MESSAGE_SIZE" == "" ];
then
MESSAGE_SIZE="150"
fi
printf "${HIGHLIGHT1}What key pattern should I use?${NC}\n"
printf "(Default is S:S)"
printf "${HIGHLIGHT1}>>>${NC}"
read KEY_PATTERN
if [ "$KEY_PATTERN" == "" ];
then
KEY_PATTERN="S:S"
fi
printf "${HIGHLIGHT1}For how many seconds should I run the test?${NC}\n"
printf "(Default is 60)"
printf "${HIGHLIGHT1}>>>${NC}"
read TEST_TIME
if [ "$TEST_TIME" == "" ];
then
TEST_TIME="60"
fi
printf "${HIGHLIGHT1}How many test iterations should I run?${HIGHLIGHT1}\n"
printf "(Default is 10)"
printf "${HIGHLIGHT1}>>>${NC}"
read NUM_ITERATIONS
if [ "$NUM_ITERATIONS" == "" ];
then
NUM_ITERATIONS="10"
fi
printf "\n\n${HIGHLIGHT1}Resulting command:${NC}\n"
echo "==========================="
echo "${PATH} --ratio=${RATIO} --test-time=${TEST_TIME} -d ${MESSAGE_SIZE} -t ${NUM_THREADS} -c ${NUM_CLIENTS} --pipeline=${NUM_PIPELINES} --key-pattern=${KEY_PATTERN} --hide-histogram -x ${NUM_ITERATIONS} -s ${HOST} -p ${PORT}"
printf "\n\n${HIGHLIGHT1}Benchmark results:${NC}\n"
echo "==========================="
${PATH} --ratio=${RATIO} --test-time=${TEST_TIME} -d ${MESSAGE_SIZE} -t ${NUM_THREADS} -c ${NUM_CLIENTS} --pipeline=${NUM_PIPELINES} --key-pattern=${KEY_PATTERN} --hide-histogram -x ${NUM_ITERATIONS} -s ${HOST} -p ${PORT}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment