#!/bin/bash
function getTiming() {
start=$1
end=$2
start_s=$(echo $start | cut -d '.' -f 1)
start_ns=$(echo $start | cut -d '.' -f 2)
end_s=$(echo $end | cut -d '.' -f 1)
end_ns=$(echo $end | cut -d '.' -f 2)
time=$(( ( 10#$end_s - 10#$start_s ) * 1000 + ( 10#$end_ns / 1000000 - 10#$start_ns / 1000000 ) ))
echo "$time ms"
}
i=1;
MAX_INSERT_ROW_COUNT=$1;
start=$(date +%s.%N)
while [ $i -le $MAX_INSERT_ROW_COUNT ]
do
redis-cli -h 10.116.15.109 -p 6379 set test_perform$i test_performance
i=$(($i+1))
done
end=$(date +%s.%N)
getTiming $start $end
exit 0
本文介绍了一个使用Bash编写的脚本,该脚本用于测试Redis数据库的性能。通过设置最大插入行数并记录开始与结束时间,可以计算出Redis在特定负载下的响应时间。

648

被折叠的 条评论
为什么被折叠?



