gtr,parser/gotest: Add test 27

This commit is contained in:
Joël Stemmer 2019-10-05 19:12:35 +01:00
parent be29a47155
commit 1a0c32347c
3 changed files with 18 additions and 8 deletions

View File

@ -46,7 +46,7 @@ type Event struct {
// Benchmarks
Iterations int64
NsPerOp int64
NsPerOp float64
BytesPerOp int64
AllocsPerOp int64
}

View File

@ -100,7 +100,7 @@ func (p *parser) summary(result, name, duration, data, covpct, packages string)
Name: name,
Duration: parseSeconds(duration),
Data: data,
CovPct: parseCoverage(covpct),
CovPct: parseFloat(covpct),
CovPackages: parsePackages(packages),
})
}
@ -108,7 +108,7 @@ func (p *parser) summary(result, name, duration, data, covpct, packages string)
func (p *parser) coverage(percent, packages string) {
p.add(gtr.Event{
Type: "coverage",
CovPct: parseCoverage(percent),
CovPct: parseFloat(percent),
CovPackages: parsePackages(packages),
})
}
@ -118,7 +118,7 @@ func (p *parser) benchmark(name, iterations, timePerOp, bytesPerOp, allocsPerOp
Type: "benchmark",
Name: name,
Iterations: parseInt(iterations),
NsPerOp: parseInt(timePerOp),
NsPerOp: parseFloat(timePerOp),
BytesPerOp: parseInt(bytesPerOp),
AllocsPerOp: parseInt(allocsPerOp),
})
@ -137,12 +137,12 @@ func parseSeconds(s string) time.Duration {
return d
}
func parseCoverage(percent string) float64 {
if percent == "" {
func parseFloat(s string) float64 {
if s == "" {
return 0
}
// ignore error
pct, _ := strconv.ParseFloat(percent, 64)
pct, _ := strconv.ParseFloat(s, 64)
return pct
}

View File

@ -400,7 +400,17 @@ var tests = []struct {
{Type: "status", Result: "PASS"},
{Type: "summary", Result: "ok", Name: "mycode/benchmarks/channels", Duration: 47084 * time.Millisecond},
}},
{"27-benchdecimal", []gtr.Event{}},
{"27-benchdecimal",
[]gtr.Event{
{Type: "output", Data: "goos: darwin"},
{Type: "output", Data: "goarch: amd64"},
{Type: "output", Data: "pkg: really/small"},
{Type: "benchmark", Name: "BenchmarkItsy", Iterations: 30000000, NsPerOp: 45.7},
{Type: "benchmark", Name: "BenchmarkTeeny", Iterations: 1000000000, NsPerOp: 2.12},
{Type: "benchmark", Name: "BenchmarkWeeny", Iterations: 2000000000, NsPerOp: 0.26},
{Type: "status", Result: "PASS"},
{Type: "summary", Result: "ok", Name: "really/small", Duration: 4344 * time.Millisecond},
}},
{"28-bench-1cpu", []gtr.Event{}},
{"29-bench-16cpu", []gtr.Event{}},
{"30-stdout", []gtr.Event{}},