#!/bin/bash

This script tests the disk performance using fio tool

Define test parameters

blocksize="4k" iodepth="32" size="1G" runtime="30s" filename="/tmp/testfile"

Define test functions

function run_test() { local testname=$1 local cmd="fio --name=$testname --ioengine=libaio --bs=$blocksize --iodepth=$iodepth --size=$size --runtime=$runtime --filename=$filename --time_based --output-format=json" local result=$(eval $cmd) echo $result }

function print_test_results() { local result=$1 local bw=$(echo $result | jq '.jobs[0].write.bw') local iops=$(echo $result | jq '.jobs[0].write.iops') echo "Write bandwidth: $bw" echo "Write IOPS: $iops" }

Run tests

echo "Running tests..." echo "" echo "Sequential write test" result=$(run_test "sequential-write") print_test_results $result echo "" echo "Random write test" result=$(run_test "random-write") print_test_results $result

Clean up

rm -f $filename

echo "Tests finished!"

用shell和fio工具写一个测试硬盘性能的脚本

原文地址: https://www.cveoy.top/t/topic/b06Y 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录