ValidatorSet copy benchmark

This commit is contained in:
Jae Kwon 2015-03-19 13:47:24 -07:00
parent 8da3ba05c0
commit ab0ee97c18

View File

@ -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()
}
}