test_cat_io_fuse.sh 628 B

1234567891011121314151617181920212223242526
  1. #!/bin/bash
  2. # 测试函数
  3. run_command_test() {
  4. local command=$1
  5. local iterations=$2
  6. echo "Testing command: $command with $iterations iterations..."
  7. total_time=0
  8. for ((i=0; i<$iterations; i++)); do
  9. start_time=$(date +%s%N)
  10. eval "$command" > /dev/null
  11. end_time=$(date +%s%N)
  12. elapsed=$(( ($end_time - $start_time) / 1000000 ))
  13. total_time=$((total_time + elapsed))
  14. done
  15. average_time=$(( total_time / iterations ))
  16. echo "Average elapsed time per iteration: $average_time ms"
  17. }
  18. # 运行测试
  19. run_command_test "cat /home/sf/os/fuses/testfile.txt" 100000