1
0
mirror of https://github.com/golang/go synced 2024-11-18 14:14:46 -07:00
go/cmd/benchcmp/benchcmp_test.go
Dominik Honnef 9f20d8c198 benchmark/parser, cmd/benchcmp: improve names of exported identifiers
Most of the names have been brought in line with the names used in
testing/BenchmarkResult. For example, NsOp becomes NsPerOp.

Additionally, "Bench" becomes "Benchmark" and "BenchSet" becomes "Set".

Change-Id: I7dfca68a804e285a87ab9692b5bb99ccb676da7f
Reviewed-on: https://go-review.googlesource.com/2610
Reviewed-by: Rob Pike <r@golang.org>
2015-01-15 01:28:17 +00:00

60 lines
1.0 KiB
Go

package main
import (
"reflect"
"testing"
"golang.org/x/tools/benchmark/parse"
)
func TestSelectBest(t *testing.T) {
have := parse.Set{
"Benchmark1": []*parse.Benchmark{
{
Name: "Benchmark1",
N: 10, NsPerOp: 100, Measured: parse.NsPerOp,
Ord: 0,
},
{
Name: "Benchmark1",
N: 10, NsPerOp: 50, Measured: parse.NsPerOp,
Ord: 3,
},
},
"Benchmark2": []*parse.Benchmark{
{
Name: "Benchmark2",
N: 10, NsPerOp: 60, Measured: parse.NsPerOp,
Ord: 1,
},
{
Name: "Benchmark2",
N: 10, NsPerOp: 500, Measured: parse.NsPerOp,
Ord: 2,
},
},
}
want := parse.Set{
"Benchmark1": []*parse.Benchmark{
{
Name: "Benchmark1",
N: 10, NsPerOp: 50, Measured: parse.NsPerOp,
Ord: 0,
},
},
"Benchmark2": []*parse.Benchmark{
{
Name: "Benchmark2",
N: 10, NsPerOp: 60, Measured: parse.NsPerOp,
Ord: 1,
},
},
}
selectBest(have)
if !reflect.DeepEqual(want, have) {
t.Errorf("filtered bench set incorrectly, want %v have %v", want, have)
}
}