-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2a023f
commit cedda22
Showing
3 changed files
with
43 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package evaluate | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// Metrics holds numerical benchmarking metrics. | ||
type Metrics struct { | ||
// Total is the total number of benchmarking candidates. | ||
Total uint | ||
// Executed is the number of benchmarking candidates with successful execution. | ||
Executed uint | ||
} | ||
|
||
// Add sums two metrics objects. | ||
func (m Metrics) Add(o Metrics) Metrics { | ||
return Metrics{ | ||
Total: m.Total + o.Total, | ||
Executed: m.Executed + o.Total, | ||
} | ||
} | ||
|
||
// String returns a string representation of the metrics. | ||
func (m Metrics) String() string { | ||
return fmt.Sprintf("#executed=%d/%d", m.Executed, m.Total) | ||
} | ||
|
||
// String returns a string representation of the metrics. | ||
func (m Metrics) StringPercentage() string { | ||
return fmt.Sprintf("#executed=%3.0f%%", float64(m.Executed)/float64(m.Total)*100.0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters