mirror of
https://github.com/everett7623/nodeloc_vps_test.git
synced 2024-12-27 16:55:21 +00:00
Update nodeloc_vps_autotest_speed.sh
This commit is contained in:
parent
310de3e271
commit
fef00b2652
@ -109,20 +109,21 @@ run_and_capture() {
|
|||||||
echo "$command_output"
|
echo "$command_output"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 去除三网测速板块ANSI转义码并截取(多线程)
|
# 去除三网测速板块ANSI转义码并截取
|
||||||
speedtest_multi_process_output() {
|
process_speedtest_output() {
|
||||||
local input="$1"
|
local input="$1"
|
||||||
# Step 1: 去除 ANSI 转义码
|
local keyword="$2"
|
||||||
|
|
||||||
|
# 去除 ANSI 转义码
|
||||||
local no_ansi
|
local no_ansi
|
||||||
no_ansi=$(echo "$input" | sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g')
|
no_ansi=$(echo "$input" | sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g')
|
||||||
|
|
||||||
# Step 2: 计算关键字出现的次数
|
# 计算关键字出现的次数
|
||||||
local count
|
local count
|
||||||
count=$(echo "$no_ansi" | grep -Fc "大陆三网+教育网 IPv4 多线程测速")
|
count=$(echo "$no_ansi" | grep -Fc "$keyword")
|
||||||
|
|
||||||
# Step 3: 提取所需的测试结果并过滤进度条
|
# 提取所需的测试结果并过滤进度条
|
||||||
local speedtest_multi_process_output_result
|
echo "$no_ansi" | awk -v count="$count" -v key="$keyword" '
|
||||||
speedtest_multi_process_output_result=$(echo "$no_ansi" | awk -v count="$count" -v key="大陆三网+教育网 IPv4 多线程测速" '
|
|
||||||
$0 == key {
|
$0 == key {
|
||||||
if (--count == 0) {
|
if (--count == 0) {
|
||||||
f=1; next
|
f=1; next
|
||||||
@ -130,35 +131,17 @@ speedtest_multi_process_output() {
|
|||||||
}
|
}
|
||||||
f && !/测试进行中/ && NF;
|
f && !/测试进行中/ && NF;
|
||||||
/系统时间:/ {exit}
|
/系统时间:/ {exit}
|
||||||
')
|
'
|
||||||
|
|
||||||
echo "$speedtest_multi_process_output_result"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# 去除三网测速板块ANSI转义码并截取(单线程)
|
# 提取三网测速板块(多线程)
|
||||||
|
speedtest_multi_process_output() {
|
||||||
|
process_speedtest_output "$1" "大陆三网+教育网 IPv4 多线程测速"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 提取三网测速板块(单线程)
|
||||||
speedtest_single_process_output() {
|
speedtest_single_process_output() {
|
||||||
local input="$1"
|
process_speedtest_output "$1" "大陆三网+教育网 IPv4 单线程测速"
|
||||||
# Step 1: 去除 ANSI 转义码
|
|
||||||
local no_ansi
|
|
||||||
no_ansi=$(echo "$input" | sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g')
|
|
||||||
|
|
||||||
# Step 2: 计算关键字出现的次数
|
|
||||||
local count
|
|
||||||
count=$(echo "$no_ansi" | grep -Fc "大陆三网+教育网 IPv4 单线程测速")
|
|
||||||
|
|
||||||
# Step 3: 提取所需的测试结果并过滤进度条
|
|
||||||
local speedtest_single_process_output_result
|
|
||||||
speedtest_single_process_output_result=$(echo "$no_ansi" | awk -v count="$count" -v key="大陆三网+教育网 IPv4 单线程测速" '
|
|
||||||
$0 == key {
|
|
||||||
if (--count == 0) {
|
|
||||||
f=1; next
|
|
||||||
}
|
|
||||||
}
|
|
||||||
f && !/测试进行中/ && NF;
|
|
||||||
/系统时间:/ {exit}
|
|
||||||
')
|
|
||||||
|
|
||||||
echo "$speedtest_single_process_output_result"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# 运行所有测试
|
# 运行所有测试
|
||||||
@ -180,10 +163,8 @@ run_all_tests() {
|
|||||||
format_results() {
|
format_results() {
|
||||||
|
|
||||||
# 处理三网测速结果
|
# 处理三网测速结果
|
||||||
local processed_speedtest_multi_result
|
local processed_speedtest_multi_result=$(speedtest_multi_process_output "$speedtest_multi_result")
|
||||||
local processed_speedtest_single_result
|
local processed_speedtest_single_result=$(speedtest_single_process_output "$speedtest_single_result")
|
||||||
processed_speedtest_multi_result=$(speedtest_multi_process_output "$speedtest_multi_result")
|
|
||||||
processed_speedtest_single_result=$(speedtest_single_process_output "$speedtest_single_result")
|
|
||||||
|
|
||||||
result="[tabs]
|
result="[tabs]
|
||||||
[tab=\"多线程测速\"]
|
[tab=\"多线程测速\"]
|
||||||
|
Loading…
Reference in New Issue
Block a user