使用shell模拟并发测试
侧边栏壁纸
  • 累计撰写 50 篇文章
  • 累计收到 0 条评论

使用shell模拟并发测试

admin
2024-02-27 / 0 评论 / 137 阅读 / 正在检测是否收录...
#!/bin/bash

start_time=$(date +%s)

end_time=$((start_time + 3600))

while true
do
  current_time=$(date +%s)

  if [ $current_time -gt $end_time ]; then
    break
  fi

  for ((i=1; i<=10000; i++))
  do
    curl 'https://xxxx.xxxx.net/api/graphql/backend' \
      -H 'accept: application/json' \
      -H 'authorization: Bearer xxxxxxxxxxxx' \
      -H 'content-type: application/json' \
      --data-raw "user_id: $i" \
      --compressed

    echo $i

    if (( $i % 100 == 0 )); then
      sleep 1
    fi
  done

  sleep 1
done
0

评论 (0)

取消