Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix speed test under non-english linux. #5929

Merged
merged 1 commit into from
Dec 5, 2024
Merged

Conversation

Redbeanw44602
Copy link
Contributor

Due to i18n reasons, time= should not be used in patterns.

I modified the pattern to match the average time and now it works fine.
There is a slight difference between the macOS and linux ping command outputs, which is reflected in the ? area, so I won't match them.

...
??? min/avg/max/???? = 26.916/28.208/29.500/1.292 ms

data = try { function () return os.iorun("%s -c 1 -W 1 -n %s", ping.program, host) end }
if not data then
data = try { function () return os.iorun("%s -c 1 -W 1 %s", ping.program, host) end }
end
end
local timeval = "65535"
if data then
timeval = data:match("time[=<]([%d%s%.]-)ms", 1, true) or data:match("[=<]([%d%s%.]-)ms TTL", 1, true) or "65535"
timeval = data:match("= [^/]+/([^/]+)/", 1, true) or data:match("[=<]([%d%s%.]-)ms TTL", 1, true) or "65535"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你确定这样 匹配能过么?lua 不支持正则的哦。。/ ... / 这两是啥?

而且 mac 下 ping, = 号后面是没空格的哦。time=28.503 ms

PING www.a.shifen.com (180.101.50.242): 56 data bytes
64 bytes from 180.101.50.242: icmp_seq=0 ttl=49 time=28.503 ms
64 bytes from 180.101.50.242: icmp_seq=1 ttl=49 time=30.137 ms

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping结束后最后会输出一行

??? min/avg/max/???? = 26.916/28.208/29.500/1.292 ms

这样的东西,我在上面写了。
这个等于号是 ???? = 这里的等于号,后面是略过第一个/前的内容(匹配平均时长)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我当然知道lua不支持正则(

这个模式在我的linux上是work的

pinging the host(github.com) ... 91 ms

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mac 下试了下可以,win 测试过吗 可以不

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

win的模式是or后面那个,我试过是可以的,没有动。

@waruqi waruqi added this to the v2.9.7 milestone Dec 5, 2024
@waruqi waruqi merged commit a9b53eb into xmake-io:dev Dec 5, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants