mirror of
https://github.com/status-im/simulation.git
synced 2025-02-23 20:38:07 +00:00
25 lines
595 B
Go
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)
|
||
|
}
|