Commit 4d98753c authored by Anders Jensen Løvig's avatar Anders Jensen Løvig
Browse files

Merge branch 'master' of gitlab.au.dk:dissys/bsc-shamir

parents 580f41ae 5f57f637
Pipeline #21400 passed with stages
in 1 minute
......@@ -90,11 +90,11 @@ func BenchmarkBallotsTrusted(b *testing.B) {
b.Run("17 of 17 servers", func(b *testing.B) { benchmarkBallots(1, 17, 17, b) })
}
///////////////////////
///Server benchmarks///
///////////////////////
///////////////////////////////
///Server - Tally benchmarks///
///////////////////////////////
func benchmarkServer(votecount, serverCount, reqServer int, b *testing.B) {
func benchmarkTally(votecount, serverCount, reqServer int, b *testing.B) {
for i := 0; i < b.N; i++ {
//Setup
b.StopTimer()
......@@ -110,10 +110,92 @@ func benchmarkServer(votecount, serverCount, reqServer int, b *testing.B) {
}
}
func BenchmarkServerBallot(b *testing.B) {
b.Run("10 Votes", func(b *testing.B) { benchmarkServer(10, 5, 3, b) })
b.Run("100 Votes", func(b *testing.B) { benchmarkServer(100, 5, 3, b) })
func BenchmarkBallotVote(b *testing.B) {
b.Run("10 Votes", func(b *testing.B) { benchmarkTally(10, 5, 3, b) })
b.Run("100 Votes", func(b *testing.B) { benchmarkTally(100, 5, 3, b) })
b.Run("1000 Votes", func(b *testing.B) { benchmarkTally(1000, 5, 3, b) })
b.Run("10000 Votes", func(b *testing.B) { benchmarkTally(10000, 5, 3, b) })
b.Run("100000 Votes", func(b *testing.B) { benchmarkTally(100000, 5, 3, b) })
}
func BenchmarkBallotServer(b *testing.B) {
b.Run("9 of 9 servers", func(b *testing.B) { benchmarkTally(100, 9, 9, b) })
b.Run("9 of 11 servers", func(b *testing.B) { benchmarkTally(100, 11, 9, b) })
b.Run("9 of 13 servers", func(b *testing.B) { benchmarkTally(100, 13, 9, b) })
b.Run("9 of 15 servers", func(b *testing.B) { benchmarkTally(100, 15, 9, b) })
b.Run("9 of 17 servers", func(b *testing.B) { benchmarkTally(100, 17, 9, b) })
}
func BenchmarkBallotRequired(b *testing.B) {
log.SetOutput(ioutil.Discard)
b.Run("9 of 17 servers", func(b *testing.B) { benchmarkTally(100, 17, 9, b) })
b.Run("11 of 17 servers", func(b *testing.B) { benchmarkTally(100, 17, 11, b) })
b.Run("13 of 17 servers", func(b *testing.B) { benchmarkTally(100, 17, 13, b) })
b.Run("15 of 17 servers", func(b *testing.B) { benchmarkTally(100, 17, 15, b) })
b.Run("17 of 17 servers", func(b *testing.B) { benchmarkTally(100, 17, 17, b) })
}
///////////////////////////////
///Server - Combine benchmarks///
///////////////////////////////
var resultcombine *big.Int
func benchmarkCombine(votecount, serverCount, reqServer int, b *testing.B) {
log.SetOutput(ioutil.Discard)
var r *big.Int
//Setup
b.StopTimer()
votes := setupVote(votecount)
xs := createXS(serverCount)
ballots := createAllBallots(votes, serverCount, reqServer, xs, makeBallots(votecount, serverCount))
ballotBoxes := make([]*BallotBox, serverCount)
tallyBoxes := make([]*TallyBox, serverCount)
for i := 0; i < serverCount; i++ {
tallyBoxes[i] = NewTallyBox(common.DefaultParams())
ballotBoxes[i] = NewBallotBox(xs[i], common.DefaultParams())
}
for i, ballotbox := range ballotBoxes {
ID := UniqueID(strconv.Itoa(i + 1))
for _, ballot := range ballots {
ballotbox.Put(ballot[ID])
}
tally := ballotbox.Tally()
for i := 0; i < reqServer; i++ {
tallyBoxes[0].Put(tally)
}
}
//Actual benchmark
b.StartTimer()
for i := 0; i < b.N; i++ {
r = tallyBoxes[0].Combine()
}
resultcombine = r
}
func BenchmarkCombineVote(b *testing.B) {
log.SetOutput(ioutil.Discard)
b.Run("10 Votes", func(b *testing.B) { benchmarkCombine(10, 5, 3, b) })
b.Run("100 Votes", func(b *testing.B) { benchmarkCombine(100, 5, 3, b) })
b.Run("1000 Votes", func(b *testing.B) { benchmarkCombine(1000, 5, 3, b) })
b.Run("10000 Votes", func(b *testing.B) { benchmarkCombine(10000, 5, 3, b) })
b.Run("100000 Votes", func(b *testing.B) { benchmarkCombine(100000, 5, 3, b) })
}
func BenchmarkCombineServer(b *testing.B) {
log.SetOutput(ioutil.Discard)
b.Run("9 of 9 servers", func(b *testing.B) { benchmarkCombine(100, 9, 9, b) })
b.Run("9 of 11 servers", func(b *testing.B) { benchmarkCombine(100, 11, 9, b) })
b.Run("9 of 13 servers", func(b *testing.B) { benchmarkCombine(100, 13, 9, b) })
b.Run("9 of 15 servers", func(b *testing.B) { benchmarkCombine(100, 15, 9, b) })
b.Run("9 of 17 servers", func(b *testing.B) { benchmarkCombine(100, 17, 9, b) })
}
func BenchmarkCombineRequired(b *testing.B) {
log.SetOutput(ioutil.Discard)
b.Run("9 of 17 servers", func(b *testing.B) { benchmarkCombine(100, 17, 9, b) })
b.Run("11 of 17 servers", func(b *testing.B) { benchmarkCombine(100, 17, 11, b) })
b.Run("13 of 17 servers", func(b *testing.B) { benchmarkCombine(100, 17, 13, b) })
b.Run("15 of 17 servers", func(b *testing.B) { benchmarkCombine(100, 17, 15, b) })
b.Run("17 of 17 servers", func(b *testing.B) { benchmarkCombine(100, 17, 17, b) })
}
// Actual tests
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment