2014-12-23 18:15:25 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"golang.org/x/tools/benchmark/parse"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSelectBest(t *testing.T) {
|
2015-01-09 01:47:44 -07:00
|
|
|
have := parse.Set{
|
|
|
|
"Benchmark1": []*parse.Benchmark{
|
2014-12-23 18:15:25 -07:00
|
|
|
{
|
|
|
|
Name: "Benchmark1",
|
2015-01-09 01:47:44 -07:00
|
|
|
N: 10, NsPerOp: 100, Measured: parse.NsPerOp,
|
2014-12-23 18:15:25 -07:00
|
|
|
Ord: 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "Benchmark1",
|
2015-01-09 01:47:44 -07:00
|
|
|
N: 10, NsPerOp: 50, Measured: parse.NsPerOp,
|
2014-12-23 18:15:25 -07:00
|
|
|
Ord: 3,
|
|
|
|
},
|
|
|
|
},
|
2015-01-09 01:47:44 -07:00
|
|
|
"Benchmark2": []*parse.Benchmark{
|
2014-12-23 18:15:25 -07:00
|
|
|
{
|
|
|
|
Name: "Benchmark2",
|
2015-01-09 01:47:44 -07:00
|
|
|
N: 10, NsPerOp: 60, Measured: parse.NsPerOp,
|
2014-12-23 18:15:25 -07:00
|
|
|
Ord: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "Benchmark2",
|
2015-01-09 01:47:44 -07:00
|
|
|
N: 10, NsPerOp: 500, Measured: parse.NsPerOp,
|
2014-12-23 18:15:25 -07:00
|
|
|
Ord: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2015-01-09 01:47:44 -07:00
|
|
|
want := parse.Set{
|
|
|
|
"Benchmark1": []*parse.Benchmark{
|
2014-12-23 18:15:25 -07:00
|
|
|
{
|
|
|
|
Name: "Benchmark1",
|
2015-01-09 01:47:44 -07:00
|
|
|
N: 10, NsPerOp: 50, Measured: parse.NsPerOp,
|
2014-12-23 18:15:25 -07:00
|
|
|
Ord: 0,
|
|
|
|
},
|
|
|
|
},
|
2015-01-09 01:47:44 -07:00
|
|
|
"Benchmark2": []*parse.Benchmark{
|
2014-12-23 18:15:25 -07:00
|
|
|
{
|
|
|
|
Name: "Benchmark2",
|
2015-01-09 01:47:44 -07:00
|
|
|
N: 10, NsPerOp: 60, Measured: parse.NsPerOp,
|
2014-12-23 18:15:25 -07:00
|
|
|
Ord: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
selectBest(have)
|
|
|
|
if !reflect.DeepEqual(want, have) {
|
|
|
|
t.Errorf("filtered bench set incorrectly, want %v have %v", want, have)
|
|
|
|
}
|
|
|
|
}
|