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

With a little concurrency, the detection quality is very poor and plummets #111

Open
MrGlp opened this issue Jul 4, 2024 · 0 comments
Open

Comments

@MrGlp
Copy link

MrGlp commented Jul 4, 2024

Please help me if you can, thank you very much, I have to fix this quickly to get off work and go on a date with Ms. Amin

issue:
For the unit test below
If the expectAppendTimes is 300, more than %50 AvgRtt is 100ms(time out)
If the expectAppendTimes is 100, 100% AvgRtt is 50ms(not time out)
I think there is a resource bottleneck that makes it impossible to be concurrent, the test environment is win11, and centos also reproduces the same similar problem, how to solve the optimization

func TestPingIPv4(t *testing.T) {
	ip := net.ParseIP(const_dc.LocalAddressIpv4)
	t.Log(ip.String())
	addrArr := []string{
		"www.baidu.com",
		"www.qq.com",
		"www.alibaba.com",
	}
	expectAppendTimes := 300
	for i := range iter.N(expectAppendTimes) {
		addrArr = append(addrArr, addrArr[i%3])
	}
	expectTimes := 1
	expectTimeDuration := 100 * time.Millisecond
	for iTmp, addrTmp := range addrArr {
		i := iTmp
		addr := addrTmp
		go func() {
			got, err := PingIPv4(addr, expectTimes, expectTimeDuration)
			if err != nil {
				t.Error(err.Error())
			}
			if got.PacketsRecv == 0 || got.AvgRtt > expectTimeDuration {
				t.Log(i, 100*time.Millisecond)
			} else {
				t.Log(i, got.AvgRtt)
			}
		}()
	}
	time.Sleep(time.Minute)
}
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

No branches or pull requests

1 participant