sort suite so benchmarks always run in the same order

License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
This commit is contained in:
Adrian Lanzafame 2018-10-29 20:16:51 +10:00
parent ee43bc1951
commit 308d998d76
No known key found for this signature in database
GPG Key ID: 87E40C5D62EAE192

View File

@ -3,6 +3,7 @@ package test
import (
"context"
"fmt"
"sort"
"testing"
pstore "github.com/libp2p/go-libp2p-peerstore"
@ -38,7 +39,15 @@ func BenchmarkPeerstore(b *testing.B, factory PeerstoreFactory, variant string)
go addressProducer(ctx, b, p.ch, p.n)
}
for name, bench := range peerstoreBenchmarks {
// So tests are always run in the same order.
ordernames := make([]string, 0, len(peerstoreBenchmarks))
for name := range peerstoreBenchmarks {
ordernames = append(ordernames, name)
}
sort.Strings(ordernames)
for _, name := range ordernames {
bench := peerstoreBenchmarks[name]
for _, p := range params {
// Create a new peerstore.
ps, closeFunc := factory()