mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-05-20 19:04:29 -05:00
gtr,junit: Move Benchmark duration calculation to gtr package
This commit is contained in:
parent
cb055227b7
commit
9a1666d75c
@ -103,6 +103,12 @@ type Benchmark struct {
|
|||||||
AllocsPerOp int64
|
AllocsPerOp int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ApproximateDuration returns the duration calculated by multiplying the
|
||||||
|
// iterations and average time per iteration (NsPerOp).
|
||||||
|
func (b Benchmark) ApproximateDuration() time.Duration {
|
||||||
|
return time.Duration(b.NsPerOp) * time.Duration(b.Iterations)
|
||||||
|
}
|
||||||
|
|
||||||
// Error contains details of a build or runtime error.
|
// Error contains details of a build or runtime error.
|
||||||
type Error struct {
|
type Error struct {
|
||||||
ID int
|
ID int
|
||||||
|
@ -235,7 +235,7 @@ func createTestcaseForBenchmark(pkgName string, bm gtr.Benchmark) Testcase {
|
|||||||
tc := Testcase{
|
tc := Testcase{
|
||||||
Classname: pkgName,
|
Classname: pkgName,
|
||||||
Name: bm.Name,
|
Name: bm.Name,
|
||||||
Time: formatBenchmarkTime(time.Duration(bm.NsPerOp) * time.Duration(bm.Iterations)),
|
Time: formatBenchmarkTime(bm.ApproximateDuration()),
|
||||||
}
|
}
|
||||||
|
|
||||||
if bm.Result == gtr.Fail {
|
if bm.Result == gtr.Fail {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user