From 75cd522c2c73fcf017a696b86556cce868791148 Mon Sep 17 00:00:00 2001 From: JustSong Date: Thu, 22 Jun 2023 19:14:31 +0800 Subject: [PATCH] chore: add time_test.sh --- bin/time_test.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 bin/time_test.sh diff --git a/bin/time_test.sh b/bin/time_test.sh new file mode 100644 index 00000000..592b4cd0 --- /dev/null +++ b/bin/time_test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +if [ $# -ne 3 ]; then + echo "Usage: time_test.sh " + exit 1 +fi + +domain=$1 +key=$2 +count=$3 +total_time=0 + +for ((i=1; i<=count; i++)); do + result=$(curl -o /dev/null -s -w %{time_total}\\n \ + https://"$domain"/v1/chat/completions \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $key" \ + -d '{"prompt": "hi!", "max_tokens": 1}') + echo "$result" + total_time=$(echo "$total_time + $result" | bc) +done + +average_time=$(echo "scale=3; $total_time / $count" | bc) +echo "Average time: $average_time" +