Browse Source

ValidatorSet copy benchmark

pull/32/head
Jae Kwon 10 years ago
parent
commit
ab0ee97c18
1 changed files with 20 additions and 0 deletions
  1. +20
    -0
      state/validator_set_test.go

+ 20
- 0
state/validator_set_test.go 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()
}
}

Loading…
Cancel
Save