LoginSignup
1
0

More than 5 years have passed since last update.

curlを100回やってダウンロード時間の平均を求める

Posted at

クラウドのスピード試す時に使ってた

#!/bin/bash

# スピード調査をするURL群(スペース区切り)
D="example.com www1.example.com www2.example.com"

# 平均を取るために繰り返す回数
RPT=100

echo '%{time_total}' > curl-format.txt

for R in $D
do
   TIME=0
   echo $R
   echo

   for i in $(seq 1 $RPT)
   do
#       echo i=$i
       TRY=$(curl -w "@curl-format.txt" -o /dev/null -s $R)
       TIME=$( python -c "print $TRY+$TIME") 
   done

#   echo TIME=$TIME
#   echo RPT=$RPT
   RES=$( python -c "print float($TIME)/$RPT" )
   echo $R avarage is $RES
   echo

done
1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0