MongoDB存储引擎性能对比与分析
1. 插入性能测试
1.1 测试脚本
插入性能测试脚本会对服务器启动、插入操作和服务器关闭过程进行计时,并在关闭后测量存储目录的磁盘使用情况。以下是相关脚本代码:
done
T="$(($(date +%s)-T))"
echo
echo "Insert performance for $config: $T seconds"
echo -ne "Shutting down server... "
T="$(date +%s)"
./bin/mongo admin --quiet --eval "db.shutdownServer({force: true})" >/dev/null 2>&1
while [ 1 ]; do
pgrep -U $USER mongod > /dev/null 2>&1
if [ "$?" -eq 1 ]; then
break
fi
sleep 1
done
T="$(($(date +%s)-T))"
echo "took $T seconds"
SIZE=$(du -s --block-size=1 $MONGO_DIR/$DATA_DIR | cut -f1)
SIZE_MB=$(echo "scale=2; $SIZE/(1024*1024)" | bc)
echo "Disk usage for $config: ${SIZE_MB}MB"
此脚本假设MongoDB安装在脚本所在目录的 bin
超级会员免费看
订阅专栏 解锁全文
2334

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



