mirror of
				https://github.com/linux-do/new-api.git
				synced 2025-11-04 13:23:42 +08:00 
			
		
		
		
	chore: update time_test.sh
This commit is contained in:
		@@ -9,6 +9,7 @@ domain=$1
 | 
			
		||||
key=$2
 | 
			
		||||
count=$3
 | 
			
		||||
total_time=0
 | 
			
		||||
times=()
 | 
			
		||||
 | 
			
		||||
for ((i=1; i<=count; i++)); do
 | 
			
		||||
  result=$(curl -o /dev/null -s -w %{time_total}\\n \
 | 
			
		||||
@@ -17,9 +18,19 @@ for ((i=1; i<=count; i++)); do
 | 
			
		||||
           -H "Authorization: Bearer $key" \
 | 
			
		||||
           -d '{"prompt": "hi!", "max_tokens": 1}')
 | 
			
		||||
  echo "$result"
 | 
			
		||||
  total_time=$(echo "$total_time + $result" | bc)
 | 
			
		||||
  total_time=$(bc <<< "$total_time + $result")
 | 
			
		||||
  times+=("$result")
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
average_time=$(echo "scale=3; $total_time / $count" | bc)
 | 
			
		||||
echo "Average time: $average_time"
 | 
			
		||||
average_time=$(echo "scale=4; $total_time / $count" | bc)
 | 
			
		||||
 | 
			
		||||
sum_of_squares=0
 | 
			
		||||
for time in "${times[@]}"; do
 | 
			
		||||
  difference=$(echo "scale=4; $time - $average_time" | bc)
 | 
			
		||||
  square=$(echo "scale=4; $difference * $difference" | bc)
 | 
			
		||||
  sum_of_squares=$(echo "scale=4; $sum_of_squares + $square" | bc)
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
standard_deviation=$(echo "scale=4; sqrt($sum_of_squares / $count)" | bc)
 | 
			
		||||
 | 
			
		||||
echo "Average time: $average_time±$standard_deviation"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user