mirror of
https://github.com/everett7623/nodeloc_vps_test.git
synced 2025-01-30 17:06:16 +00:00
Update Nlbench.sh
This commit is contained in:
parent
c3b2e3610a
commit
313bf268e7
69
Nlbench.sh
69
Nlbench.sh
@ -175,39 +175,56 @@ response_process_output() {
|
|||||||
echo "$input" | sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g'
|
echo "$input" | sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g'
|
||||||
}
|
}
|
||||||
|
|
||||||
# 去除三网测速板块板块ANSI转义码并截取(多线程)
|
# 去除三网测速板块板块ANSI转义码并截取
|
||||||
speedtest_multi_process_output() {
|
process_speedtest_output() {
|
||||||
local input="$1"
|
local input="$1"
|
||||||
# Step 1: 去除 ANSI 转义码
|
local keyword="$2"
|
||||||
|
|
||||||
|
echo "Debug: Processing for keyword: $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')
|
||||||
echo "去除 ANSI 转义码后的输出: $no_ansi" >&2
|
|
||||||
|
|
||||||
# Step 2: 过滤掉包含 "测试进行中" 的行
|
echo "Debug: Input after ANSI removal (first 500 chars):" >&2
|
||||||
local no_progress=$(echo "$no_ansi" | grep -v "^ *测试进行中")
|
echo "${no_ansi:0:500}" >&2
|
||||||
echo "过滤掉包含 '测试进行中' 的行后的输出: $no_progress" >&2
|
|
||||||
|
|
||||||
# Step 3: 截取所需的测试结果
|
# 计算关键字出现的次数
|
||||||
local speedtest_multi_process_output_result=$(echo "$no_progress" | awk '/大陆三网\+教育网 IPv4 多线程测速/{f=1} f; /北京时间/{f=0}')
|
local count
|
||||||
echo "$speedtest_multi_process_output_result"
|
count=$(echo "$no_ansi" | grep -Fc "$keyword")
|
||||||
|
|
||||||
|
echo "Debug: Keyword count: $count" >&2
|
||||||
|
|
||||||
|
# 提取所需的测试结果并过滤进度条
|
||||||
|
local result
|
||||||
|
result=$(echo "$no_ansi" | awk -v count="$count" -v key="$keyword" '
|
||||||
|
BEGIN { found = 0 }
|
||||||
|
$0 ~ key {
|
||||||
|
print "Debug: Found keyword, remaining count: " count > "/dev/stderr"
|
||||||
|
if (--count == 0) {
|
||||||
|
found = 1
|
||||||
|
print "Debug: Starting to capture output" > "/dev/stderr"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
found && !/测试进行中/ && NF {
|
||||||
|
print "Debug: Capturing line: " $0 > "/dev/stderr"
|
||||||
|
print
|
||||||
|
}
|
||||||
|
/------------------------ 多功能 自更新 测速脚本 ------------------------/ && count == 0 {
|
||||||
|
print "Debug: Reached end marker" > "/dev/stderr"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
')
|
||||||
|
|
||||||
|
echo "Debug: Result (first 500 chars):" >&2
|
||||||
|
echo "${result:0:500}" >&2
|
||||||
|
|
||||||
|
echo "$result"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 去除三网测速板块板块ANSI转义码并截取(单线程)
|
speedtest_process_output() {
|
||||||
speedtest_single_process_output() {
|
echo "Debug: Calling speedtest process" >&2
|
||||||
local input="$1"
|
process_speedtest_output "$1" "多功能 自更新 测速脚本"
|
||||||
# Step 1: 去除 ANSI 转义码
|
|
||||||
local no_ansi
|
|
||||||
no_ansi=$(echo "$input" | sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g')
|
|
||||||
echo "去除 ANSI 转义码后的输出: $no_ansi" >&2
|
|
||||||
|
|
||||||
# Step 2: 过滤掉包含 "测试进行中" 的行
|
|
||||||
local no_progress
|
|
||||||
no_progress=$(echo "$no_ansi" | grep -v "^ *测试进行中")
|
|
||||||
echo "过滤掉包含 '测试进行中' 的行后的输出: $no_progress" >&2
|
|
||||||
|
|
||||||
# Step 3: 截取所需的测试结果
|
|
||||||
local speedtest_single_process_output_result=$(echo "$no_progress" | awk '/大陆三网\+教育网 IPv4 单线程测速/{f=1} f; /北京时间/{f=0}')
|
|
||||||
echo "$speedtest_single_process_output_result"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# 去除回程路由板块板块ANSI转义码并截取
|
# 去除回程路由板块板块ANSI转义码并截取
|
||||||
|
Loading…
Reference in New Issue
Block a user