mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
ValidatorSet copy benchmark
This commit is contained in:
parent
8da3ba05c0
commit
ab0ee97c18
@ -40,3 +40,23 @@ func TestCopy(t *testing.T) {
|
||||
t.Fatalf("ValidatorSet copy had wrong hash. Orig: %X, Copy: %X", vsetHash, vsetCopyHash)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkValidatorSetCopy(b *testing.B) {
|
||||
b.StopTimer()
|
||||
vset := NewValidatorSet([]*Validator{})
|
||||
for i := 0; i < 1000; i++ {
|
||||
privAccount := account.GenPrivAccount()
|
||||
val := &Validator{
|
||||
Address: privAccount.Address,
|
||||
PubKey: privAccount.PubKey.(account.PubKeyEd25519),
|
||||
}
|
||||
if !vset.Add(val) {
|
||||
panic("Failde to add validator")
|
||||
}
|
||||
}
|
||||
b.StartTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
vset.Copy()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user