From 99fed1f8507170a9d38d25521f4249de8bc6fc37 Mon Sep 17 00:00:00 2001 From: mrhaoji Date: Sun, 25 Jun 2023 22:58:16 +0800 Subject: [PATCH] chore: show the HTTP status code in the test_time script to determine the success or failure of the request (#200) --- bin/time_test.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/time_test.sh b/bin/time_test.sh index e6d7a22a..578e43da 100644 --- a/bin/time_test.sh +++ b/bin/time_test.sh @@ -12,14 +12,16 @@ total_time=0 times=() for ((i=1; i<=count; i++)); do - result=$(curl -o /dev/null -s -w %{time_total}\\n \ + result=$(curl -o /dev/null -s -w "%{http_code} %{time_total}\\n" \ https://"$domain"/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $key" \ -d '{"messages": [{"content": "echo hi", "role": "user"}], "model": "gpt-3.5-turbo", "stream": false, "max_tokens": 1}') - echo "$result" - total_time=$(bc <<< "$total_time + $result") - times+=("$result") + http_code=$(echo "$result" | awk '{print $1}') + time=$(echo "$result" | awk '{print $2}') + echo "HTTP status code: $http_code, Time taken: $time" + total_time=$(bc <<< "$total_time + $time") + times+=("$time") done average_time=$(echo "scale=4; $total_time / $count" | bc)