Skip to content

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

@MrGlp

Description

@MrGlp

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)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions