update print format
This commit is contained in:
parent
ab6390a4a4
commit
7301d32cbe
10
README.md
10
README.md
|
@ -61,7 +61,7 @@ chmod +x CloudflareST
|
|||
|
||||
### 结果示例
|
||||
|
||||
测速完毕后,默认会显示**最快的 20 个 IP**,示例(我联通白天测速结果):
|
||||
测速完毕后,默认会显示**最快的 10 个 IP**,示例(我联通白天测速结果):
|
||||
|
||||
``` bash
|
||||
IP 地址 已发送 已接收 丢包率 平均延迟 下载速度 (MB/s)
|
||||
|
@ -116,8 +116,8 @@ https://github.com/XIU2/CloudflareSpeedTest
|
|||
延迟测速次数;单个 IP 延迟测速次数,为 1 时将过滤丢包的IP,TCP协议;(默认 4 )
|
||||
-tp 443
|
||||
延迟测速端口;延迟测速 TCP 协议的端口;(默认 443 )
|
||||
-dn 20
|
||||
下载测速数量;延迟测速并排序后,从最低延迟起下载测速的数量;(默认 20 )
|
||||
-dn 10
|
||||
下载测速数量;延迟测速并排序后,从最低延迟起下载测速的数量;(默认 10 )
|
||||
-dt 10
|
||||
下载测速时间;单个 IP 下载测速最长时间,单位:秒;(默认 10 )
|
||||
-url https://cf.xiu2.xyz/Github/CloudflareSpeedTest.png
|
||||
|
@ -128,8 +128,8 @@ https://github.com/XIU2/CloudflareSpeedTest
|
|||
平均延迟下限;只输出高于指定平均延迟的 IP,可与其他上限/下限搭配,过滤被假蔷的 IP;(默认 0 ms)
|
||||
-sl 5
|
||||
下载速度下限;只输出高于指定下载速度的 IP,凑够指定数量 [-dn] 才会停止测速;(默认 0.00 MB/s)
|
||||
-p 20
|
||||
显示结果数量;测速后直接显示指定数量的结果,为 0 时不显示结果直接退出;(默认 20 )
|
||||
-p 10
|
||||
显示结果数量;测速后直接显示指定数量的结果,为 0 时不显示结果直接退出;(默认 10 )
|
||||
-f ip.txt
|
||||
IP段数据文件;如路径含有空格请加上引号;支持其他 CDN IP段;(默认 ip.txt )
|
||||
-o result.csv
|
||||
|
|
|
@ -66,7 +66,7 @@ func (p *Ping) Run() utils.PingDelaySet {
|
|||
if IPv6 { // IPv6 模式判断
|
||||
ipVersion = "IPv6"
|
||||
}
|
||||
fmt.Printf("开始延迟测速(模式:TCP %s,端口:%d ,平均延迟上限:%v,平均延迟下限:%v)\n", ipVersion, TCPPort, utils.InputMaxDelay, utils.InputMinDelay)
|
||||
fmt.Printf("开始延迟测速(模式:TCP %s,端口:%d,平均延迟上限:%vms,平均延迟下限:%vms)\n", ipVersion, TCPPort, utils.InputMaxDelay.Milliseconds(), utils.InputMinDelay.Milliseconds())
|
||||
for _, ip := range p.ips {
|
||||
p.wg.Add(1)
|
||||
p.control <- false
|
||||
|
|
|
@ -20,7 +20,7 @@ var (
|
|||
InputMaxDelay = maxDelay
|
||||
InputMinDelay = minDelay
|
||||
Output = defaultOutput
|
||||
PrintNum = 20
|
||||
PrintNum = 10
|
||||
)
|
||||
|
||||
type PingData struct {
|
||||
|
@ -50,7 +50,7 @@ func (cf *CloudflareIPData) toString() []string {
|
|||
result[1] = strconv.Itoa(cf.Sended)
|
||||
result[2] = strconv.Itoa(cf.Received)
|
||||
result[3] = strconv.FormatFloat(float64(cf.getRecvRate()), 'f', 2, 32)
|
||||
result[4] = cf.Delay.String()
|
||||
result[4] = strconv.FormatFloat(cf.Delay.Seconds()*1000, 'f', 2, 32)
|
||||
result[5] = strconv.FormatFloat(cf.DownloadSpeed/1024/1024, 'f', 2, 32)
|
||||
return result
|
||||
}
|
||||
|
@ -72,7 +72,6 @@ func ExportCsv(data []CloudflareIPData) {
|
|||
w.Write([]string{"IP 地址", "已发送", "已接收", "丢包率", "平均延迟", "下载速度 (MB/s)"})
|
||||
w.WriteAll(convertToString(data))
|
||||
w.Flush()
|
||||
fmt.Printf("完整测速结果已写入 %v 文件,请使用记事本/表格软件查看。\n", Output)
|
||||
}
|
||||
|
||||
func convertToString(data []CloudflareIPData) [][]string {
|
||||
|
@ -142,7 +141,7 @@ func (s DownloadSpeedSet) Print(ipv6 bool) {
|
|||
PrintNum = len(dateString)
|
||||
}
|
||||
headFormat := "%-16s%-5s%-5s%-5s%-6s%-11s\n"
|
||||
dataFormat := "%-18s%-8s%-8s%-8s%-15s%-15s\n"
|
||||
dataFormat := "%-18s%-8s%-8s%-8s%-10s%-15s\n"
|
||||
if ipv6 { // IPv6 太长了,所以需要调整一下间隔
|
||||
headFormat = "%-40s%-5s%-5s%-5s%-6s%-11s\n"
|
||||
dataFormat = "%-42s%-8s%-8s%-8s%-10s%-15s\n"
|
||||
|
@ -151,4 +150,5 @@ func (s DownloadSpeedSet) Print(ipv6 bool) {
|
|||
for i := 0; i < PrintNum; i++ {
|
||||
fmt.Printf(dataFormat, dateString[i][0], dateString[i][1], dateString[i][2], dateString[i][3], dateString[i][4], dateString[i][5])
|
||||
}
|
||||
fmt.Printf("\n完整测速结果已写入 %v 文件,请使用记事本/表格软件查看。\n", Output)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue