simulation/stats/coverage.go
2018-04-19 10:45:51 +02:00

25 lines
595 B
Go

package stats
import "fmt"
// Coverage stores stats about coverage of large amount of units (nodes/links/etc).
type Coverage struct {
Actual int
Total int
Percentage float64
}
// NewCoverage creates new Coverage out of the actual and total numbers.
func NewCoverage(actual, total int) Coverage {
return Coverage{
Actual: actual,
Total: total,
Percentage: 100.0 / float64(total) * float64(actual),
}
}
// String implements Stringer interface for Coverage.
func (c Coverage) String() string {
return fmt.Sprintf("%.2f (%d/%d)", c.Percentage, c.Actual, c.Total)
}