func getTestResults()

in serverui.go [405:465]


func getTestResults(s *ethrSession, proto EthrProtocol, seconds uint64) []string {
	var bwTestOn, cpsTestOn, ppsTestOn, latTestOn bool
	var bw, cps, pps, latency uint64
	aggTestResult, _ := gAggregateTestResults[proto]
	test, found := s.tests[EthrTestID{proto, All}]
	if found && test.isActive {
		bwTestOn = true
		bw = atomic.SwapUint64(&test.testResult.bw, 0)
		bw /= seconds
		aggTestResult.bw += bw
		aggTestResult.cbw++

		if proto == TCP {
			cpsTestOn = true
			cps = atomic.SwapUint64(&test.testResult.cps, 0)
			cps /= seconds
			aggTestResult.cps += cps
			aggTestResult.ccps++
		}

		if proto == UDP {
			ppsTestOn = true
			pps = atomic.SwapUint64(&test.testResult.pps, 0)
			pps /= seconds
			aggTestResult.pps += pps
			aggTestResult.cpps++
		}

		if proto == TCP {
			latency = atomic.LoadUint64(&test.testResult.latency)
			if latency > 0 {
				latTestOn = true
			}
		}

		if test.isDormant && !((bwTestOn && bw != 0) || (cpsTestOn && cps != 0) || (ppsTestOn && pps != 0) || (latTestOn && latency != 0)) {
			return []string{}
		}
	}

	if bwTestOn || cpsTestOn || ppsTestOn || latTestOn {
		var bwStr, cpsStr, ppsStr, latStr string = "--  ", "--  ", "--  ", "--  "
		if bwTestOn {
			bwStr = bytesToRate(bw)
		}
		if cpsTestOn {
			cpsStr = cpsToString(cps)
		}
		if ppsTestOn {
			ppsStr = ppsToString(pps)
		}
		if latTestOn {
			latStr = durationToString(time.Duration(latency))
		}
		str := []string{s.remoteIP, protoToString(proto),
			bwStr, cpsStr, ppsStr, latStr}
		return str
	}

	return []string{}
}