Exemple #1
0
func (s *SenderStats) Report() SentReport {
	r := SentReport{
		Begin: s.begin,
		End:   s.end,
	}
	for e := s.sent.Back(); e != nil; e = e.Prev() {
		info := e.Value.(SentInfo)

		r.bytes += info.Bytes
		r.sendTime += info.SendTime
		r.Files += info.Files
		r.Errs += info.Errs
		r.ApiErrs += info.ApiErrs
		r.Timeouts += info.Timeouts
		r.BadFiles += info.BadFiles
	}
	r.Bytes = pct.Bytes(r.bytes)
	r.Duration = pct.Duration(s.end.Sub(s.begin).Seconds())
	r.Utilization = pct.Mbps(r.bytes, s.end.Sub(s.begin).Seconds()) + " Mbps"
	r.Throughput = pct.Mbps(r.bytes, r.sendTime) + " Mbps"
	return r
}
Exemple #2
0
func (s *SysTestSuite) TestMbps(t *C) {
	t.Check(pct.Mbps(0, 1.0), Equals, "0.00")
	t.Check(pct.Mbps(12749201, 0), Equals, "0.00")

	// 1 Mbps = 1048576 bytes = 8 388 608 bits = 8.39 Mbps
	t.Check(pct.Mbps(1048576, 1.0), Equals, "8.39")

	// 222566303 bytes = 1 780 530 424 bits = 1780.53 Mbps
	t.Check(pct.Mbps(222566303, 1.0), Equals, "1780.53")
	t.Check(pct.Mbps(222566303, 2.0), Equals, "890.27")
	t.Check(pct.Mbps(222566303, 300.0), Equals, "5.94")  // 5m
	t.Check(pct.Mbps(222566303, 3600.0), Equals, "0.49") // 1h
}