aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-04-03 19:43:35 +0800
committerJimmy Hu <jimmy.hu@dexon.org>2019-04-03 19:43:35 +0800
commitab2d2d131cadb28a59b51dc5d1142ef8845e2f88 (patch)
tree1e8054acc6b8d409cfe0c6e063cfe55b5307ac2c
parent1ebfe09074d9eb80ae6a3380d1b706035fd4c9c9 (diff)
downloaddexon-consensus-ab2d2d131cadb28a59b51dc5d1142ef8845e2f88.tar
dexon-consensus-ab2d2d131cadb28a59b51dc5d1142ef8845e2f88.tar.gz
dexon-consensus-ab2d2d131cadb28a59b51dc5d1142ef8845e2f88.tar.bz2
dexon-consensus-ab2d2d131cadb28a59b51dc5d1142ef8845e2f88.tar.lz
dexon-consensus-ab2d2d131cadb28a59b51dc5d1142ef8845e2f88.tar.xz
dexon-consensus-ab2d2d131cadb28a59b51dc5d1142ef8845e2f88.tar.zst
dexon-consensus-ab2d2d131cadb28a59b51dc5d1142ef8845e2f88.zip
core: add benchmark
-rw-r--r--core/dkg-tsig-protocol_test.go58
1 files changed, 50 insertions, 8 deletions
diff --git a/core/dkg-tsig-protocol_test.go b/core/dkg-tsig-protocol_test.go
index 198f50a..f6909e8 100644
--- a/core/dkg-tsig-protocol_test.go
+++ b/core/dkg-tsig-protocol_test.go
@@ -1035,13 +1035,12 @@ func benchmarkDKGGroupPubliKey(k, n int, b *testing.B) {
})
}
+ mpk := gov.DKGMasterPublicKeys(round)
+ comp := gov.DKGComplaints(round)
b.ResetTimer()
for i := 0; i < b.N; i++ {
// DKG is fininished.
- gpk, err := typesDKG.NewGroupPublicKey(round,
- gov.DKGMasterPublicKeys(round), gov.DKGComplaints(round),
- k,
- )
+ gpk, err := typesDKG.NewGroupPublicKey(round, mpk, comp, k)
if err != nil {
panic(err)
}
@@ -1080,13 +1079,12 @@ func benchmarkDKGNodePubliKeys(k, n int, b *testing.B) {
})
}
+ mpk := gov.DKGMasterPublicKeys(round)
+ comp := gov.DKGComplaints(round)
b.ResetTimer()
for i := 0; i < b.N; i++ {
// DKG is fininished.
- npks, err := typesDKG.NewNodePublicKeys(round,
- gov.DKGMasterPublicKeys(round), gov.DKGComplaints(round),
- k,
- )
+ npks, err := typesDKG.NewNodePublicKeys(round, mpk, comp, k)
if err != nil {
panic(err)
}
@@ -1095,3 +1093,47 @@ func benchmarkDKGNodePubliKeys(k, n int, b *testing.B) {
}
}
}
+
+func BenchmarkCalcQ4_7(b *testing.B) { benchmarkCalcQualified(4, 7, b) }
+func BenchmarkCalcQ9_13(b *testing.B) { benchmarkCalcQualified(9, 13, b) }
+func BenchmarkCalcQ17_24(b *testing.B) { benchmarkCalcQualified(17, 24, b) }
+func BenchmarkCalcQ81_121(b *testing.B) { benchmarkCalcQualified(81, 121, b) }
+
+func benchmarkCalcQualified(k, n int, b *testing.B) {
+ round := uint64(1)
+ reset := uint64(0)
+ _, pubKeys, err := test.NewKeys(n)
+ if err != nil {
+ panic(err)
+ }
+ gov, err := test.NewGovernance(test.NewState(DKGDelayRound,
+ pubKeys, 100, &common.NullLogger{}, true), ConfigRoundShift)
+ if err != nil {
+ panic(err)
+ }
+
+ for _, pk := range pubKeys {
+ _, pubShare := dkg.NewPrivateKeyShares(k)
+ gov.AddDKGMasterPublicKey(&typesDKG.MasterPublicKey{
+ ProposerID: types.NewNodeID(pk),
+ Round: round,
+ Reset: reset,
+ DKGID: typesDKG.NewID(types.NewNodeID(pk)),
+ PublicKeyShares: *pubShare,
+ })
+ }
+
+ mpk := gov.DKGMasterPublicKeys(round)
+ comp := gov.DKGComplaints(round)
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ // DKG is fininished.
+ _, q, err := typesDKG.CalcQualifyNodes(mpk, comp, k)
+ if err != nil {
+ panic(err)
+ }
+ if len(q) != n {
+ panic("not enough of qualify id")
+ }
+ }
+}