This commit is contained in:
李子铭 2025-03-10 15:15:28 +08:00
parent 02aeb7db1e
commit 332416bc8f
1 changed files with 10 additions and 10 deletions

View File

@ -46,9 +46,8 @@ if ! command -v jq &> /dev/null; then
exit 1
fi
# 定义高精度时间获取函数
get_time() {
local t=$(date +%s%N)
local t=$(gdate +%s%N)
echo $((10#${t:0:10} * 1000000000 + 10#${t:10:9}))
}
@ -90,14 +89,15 @@ EOF
continue
fi
# 提取code字段
api1_code=$(echo "$response_1" | jq -r '.code')
if [ "$api1_code" != "200" ]; then
echo "接口 1 返回错误code=$api1_code, 响应=$response_1" | tee -a "$log_file"
((failure_count++))
continue
fi
# 提取code字段并检查存在性
if echo "$response_1" | jq -e '.code | exists' >/dev/null 2>&1; then
api1_code=$(echo "$response_1" | jq -r '.code')
if [ "$api1_code" != "200" ]; then
echo "接口 1 返回错误code=$api1_code, 响应=$response_1" | tee -a "$log_file"
((failure_count++))
continue
fi
fi
# 测量接口 2 响应时间
start_time_2=$(get_time)