Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
DisSys Inc.
bsc-shamir
Commits
8493342a
Commit
8493342a
authored
Jun 04, 2020
by
Thomas Hoffmann
Browse files
Added config as parameter to benchmarks
parent
b1c0dc3a
Changes
2
Hide whitespace changes
Inline
Side-by-side
election/agreement_test.go
View file @
8493342a
...
...
@@ -94,7 +94,7 @@ func TestBallotIntersect(t *testing.T) {
big
.
NewInt
(
0
),
big
.
NewInt
(
1
),
big
.
NewInt
(
0
),
big
.
NewInt
(
0
),
big
.
NewInt
(
1
),
big
.
NewInt
(
0
),
big
.
NewInt
(
1
),
big
.
NewInt
(
0
),
big
.
NewInt
(
0
),
big
.
NewInt
(
1
),
},
3
,
2
,
xs
)
},
3
,
2
,
xs
,
benchConfig
()
)
for
_
,
bmap
:=
range
ballots
{
for
id
,
b
:=
range
bmap
{
...
...
@@ -133,7 +133,7 @@ func TestBallotMaxSubset(t *testing.T) {
big
.
NewInt
(
0
),
big
.
NewInt
(
1
),
big
.
NewInt
(
0
),
big
.
NewInt
(
0
),
big
.
NewInt
(
1
),
big
.
NewInt
(
0
),
big
.
NewInt
(
1
),
big
.
NewInt
(
0
),
big
.
NewInt
(
0
),
big
.
NewInt
(
1
),
},
3
,
2
,
xs
)
},
3
,
2
,
xs
,
benchConfig
()
)
for
_
,
bmap
:=
range
ballots
{
for
id
,
b
:=
range
bmap
{
...
...
election/election_test.go
View file @
8493342a
...
...
@@ -4,6 +4,7 @@ import (
"bsc-shamir/crypto/common"
"bsc-shamir/crypto/pedersen"
"bsc-shamir/crypto/sigma"
"bsc-shamir/math/zn"
"bsc-shamir/network"
"crypto/rand"
"io/ioutil"
...
...
@@ -21,6 +22,18 @@ import (
///Setup functions///
/////////////////////
func
benchConfig
()
*
common
.
Params
{
config
:=
&
common
.
Params
{
P
:
big
.
NewInt
(
3767033279
),
Q
:
big
.
NewInt
(
1883516639
),
Zp
:
zn
.
NewRing
(
big
.
NewInt
(
3767033279
)),
Zq
:
zn
.
NewRing
(
big
.
NewInt
(
1883516639
)),
G
:
big
.
NewInt
(
2
),
H
:
big
.
NewInt
(
3
),
}
return
config
}
func
setupVote
(
votecount
int
)
[]
*
big
.
Int
{
votes
:=
make
([]
*
big
.
Int
,
votecount
)
for
i
:=
0
;
i
<
votecount
;
i
++
{
...
...
@@ -29,11 +42,11 @@ func setupVote(votecount int) []*big.Int {
return
votes
}
func
createAllBallots
(
votes
[]
*
big
.
Int
,
servercount
int
,
reqserver
int
,
xs
[]
*
big
.
Int
)
[]
map
[
UniqueID
]
*
Ballot
{
func
createAllBallots
(
votes
[]
*
big
.
Int
,
servercount
int
,
reqserver
int
,
xs
[]
*
big
.
Int
,
params
*
common
.
Params
)
[]
map
[
UniqueID
]
*
Ballot
{
ballots
:=
make
([]
map
[
UniqueID
]
*
Ballot
,
len
(
votes
))
for
votenum
:=
0
;
votenum
<
len
(
votes
);
votenum
++
{
for
servernum
:=
0
;
servernum
<
servercount
;
servernum
++
{
ballots
[
votenum
]
=
CreateBallots
(
reqserver
,
xs
,
votes
[
votenum
])
ballots
[
votenum
]
=
CreateB
enchB
allots
(
reqserver
,
xs
,
votes
[
votenum
]
,
params
)
}
}
return
ballots
...
...
@@ -47,31 +60,35 @@ func createXS(n int) []*big.Int {
return
xs
}
func
CreateFakeBallots
(
xs
[]
*
big
.
Int
)
map
[
UniqueID
]
*
Ballot
{
func
CreateBenchBallots
(
t
int
,
xs
[]
*
big
.
Int
,
vote
*
big
.
Int
,
params
*
common
.
Params
)
map
[
UniqueID
]
*
Ballot
{
binder
:=
params
.
Zq
.
GetRandomElement
()
shares
,
commits
:=
pedersen
.
NewParams
(
params
)
.
Create
(
t
,
xs
,
vote
,
binder
)
proof
:=
sigma
.
NewParams
(
params
)
.
Prove
(
vote
,
binder
,
commits
[
0
])
timestamp
:=
time
.
Now
()
id
:=
uuid
.
New
()
ballots
:=
make
(
map
[
UniqueID
]
*
Ballot
)
for
_
,
x
:=
range
x
s
{
ballots
[
UniqueID
(
x
.
String
())]
=
&
Ballot
{
for
_
,
share
:=
range
share
s
{
ballots
[
UniqueID
(
share
.
X
.
String
())]
=
&
Ballot
{
ID
:
id
,
Timestamp
:
timestamp
,
Share
:
nil
,
Commits
:
pedersen
.
Proof
{
big
.
NewInt
(
0
),
big
.
NewInt
(
0
)}
,
Proofs
:
[
2
]
*
sigma
.
Proof
{
nil
,
nil
}
,
Share
:
share
,
Commits
:
commits
,
Proofs
:
proof
,
}
}
return
ballots
}
///////////////////////
///Client benchmarks///
///////////////////////
var
result
[]
map
[
UniqueID
]
*
Ballot
func
benchmarkBallots
(
votecount
,
serverCount
,
reqServer
int
,
b
*
testing
.
B
)
{
func
benchmarkBallots
(
params
*
common
.
Params
,
votecount
,
serverCount
,
reqServer
int
,
b
*
testing
.
B
)
{
var
r
[]
map
[
UniqueID
]
*
Ballot
//Setup
b
.
StopTimer
()
...
...
@@ -80,7 +97,7 @@ func benchmarkBallots(votecount, serverCount, reqServer int, b *testing.B) {
b
.
StartTimer
()
//Actual benchmark
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
r
=
createAllBallots
(
votes
,
serverCount
,
reqServer
,
xs
)
r
=
createAllBallots
(
votes
,
serverCount
,
reqServer
,
xs
,
params
)
}
result
=
r
}
...
...
@@ -88,43 +105,45 @@ func benchmarkBallots(votecount, serverCount, reqServer int, b *testing.B) {
//Variable n
func
BenchmarkClientServer
(
b
*
testing
.
B
)
{
log
.
SetOutput
(
ioutil
.
Discard
)
b
.
Run
(
"9 of 9 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
9
,
9
,
b
)
})
b
.
Run
(
"9 of 10 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
10
,
9
,
b
)
})
b
.
Run
(
"9 of 11 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
11
,
9
,
b
)
})
b
.
Run
(
"9 of 12 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
12
,
9
,
b
)
})
b
.
Run
(
"9 of 13 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
13
,
9
,
b
)
})
b
.
Run
(
"9 of 14 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
14
,
9
,
b
)
})
b
.
Run
(
"9 of 15 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
15
,
9
,
b
)
})
b
.
Run
(
"9 of 16 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
16
,
9
,
b
)
})
b
.
Run
(
"9 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
17
,
9
,
b
)
})
config
:=
benchConfig
()
b
.
Run
(
"9 of 9 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
9
,
9
,
b
)
})
b
.
Run
(
"9 of 10 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
10
,
9
,
b
)
})
b
.
Run
(
"9 of 11 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
11
,
9
,
b
)
})
b
.
Run
(
"9 of 12 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
12
,
9
,
b
)
})
b
.
Run
(
"9 of 13 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
13
,
9
,
b
)
})
b
.
Run
(
"9 of 14 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
14
,
9
,
b
)
})
b
.
Run
(
"9 of 15 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
15
,
9
,
b
)
})
b
.
Run
(
"9 of 16 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
16
,
9
,
b
)
})
b
.
Run
(
"9 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
17
,
9
,
b
)
})
}
//Variable t
func
BenchmarkClientThreshold
(
b
*
testing
.
B
)
{
log
.
SetOutput
(
ioutil
.
Discard
)
b
.
Run
(
" 9 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
17
,
9
,
b
)
})
b
.
Run
(
"10 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
17
,
10
,
b
)
})
b
.
Run
(
"11 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
17
,
11
,
b
)
})
b
.
Run
(
"12 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
17
,
12
,
b
)
})
b
.
Run
(
"13 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
17
,
13
,
b
)
})
b
.
Run
(
"14 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
17
,
14
,
b
)
})
b
.
Run
(
"15 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
17
,
15
,
b
)
})
b
.
Run
(
"16 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
17
,
16
,
b
)
})
b
.
Run
(
"17 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
1
,
17
,
17
,
b
)
})
config
:=
benchConfig
()
b
.
Run
(
" 9 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
17
,
9
,
b
)
})
b
.
Run
(
"10 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
17
,
10
,
b
)
})
b
.
Run
(
"11 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
17
,
11
,
b
)
})
b
.
Run
(
"12 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
17
,
12
,
b
)
})
b
.
Run
(
"13 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
17
,
13
,
b
)
})
b
.
Run
(
"14 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
17
,
14
,
b
)
})
b
.
Run
(
"15 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
17
,
15
,
b
)
})
b
.
Run
(
"16 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
17
,
16
,
b
)
})
b
.
Run
(
"17 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkBallots
(
config
,
1
,
17
,
17
,
b
)
})
}
///////////////////////////////
///Server - Tally benchmarks///
///////////////////////////////
func
benchmarkTally
(
votecount
,
serverCount
,
reqServer
int
,
b
*
testing
.
B
)
{
func
benchmarkTally
(
params
*
common
.
Params
,
votecount
,
serverCount
,
reqServer
int
,
b
*
testing
.
B
)
{
//Setup
b
.
StopTimer
()
box
:=
NewBallotBox
(
big
.
NewInt
(
1
),
common
.
DefaultParams
())
box
:=
NewBallotBox
(
big
.
NewInt
(
1
),
benchConfig
())
id
:=
UniqueID
(
"1"
)
for
i
:=
0
;
i
<
votecount
;
i
++
{
_
=
box
.
Put
(
CreateBallots
(
reqServer
,
createXS
(
serverCount
),
big
.
NewInt
(
1
))[
id
])
_
=
box
.
Put
(
CreateB
enchB
allots
(
reqServer
,
createXS
(
serverCount
),
big
.
NewInt
(
1
)
,
params
)[
id
])
}
ballotList
:=
box
.
ballotList
()
...
...
@@ -142,46 +161,50 @@ func benchmarkTally(votecount, serverCount, reqServer int, b *testing.B) {
func
BenchmarkTallyVote
(
b
*
testing
.
B
)
{
log
.
SetOutput
(
ioutil
.
Discard
)
b
.
Run
(
"1 Votes"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
1
,
5
,
3
,
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
)
})
config
:=
benchConfig
()
b
.
Run
(
"1 Votes"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
1
,
5
,
3
,
b
)
})
b
.
Run
(
"10 Votes"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
5
,
3
,
b
)
})
b
.
Run
(
"100 Votes"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
100
,
5
,
3
,
b
)
})
b
.
Run
(
"1000 Votes"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
1000
,
5
,
3
,
b
)
})
b
.
Run
(
"10000 Votes"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10000
,
5
,
3
,
b
)
})
b
.
Run
(
"100000 Votes"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
100000
,
5
,
3
,
b
)
})
}
func
BenchmarkTallyServer
(
b
*
testing
.
B
)
{
log
.
SetOutput
(
ioutil
.
Discard
)
b
.
Run
(
"9 of 9 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
9
,
9
,
b
)
})
b
.
Run
(
"9 of 10 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
10
,
9
,
b
)
})
b
.
Run
(
"9 of 11 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
11
,
9
,
b
)
})
b
.
Run
(
"9 of 12 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
12
,
9
,
b
)
})
b
.
Run
(
"9 of 13 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
13
,
9
,
b
)
})
b
.
Run
(
"9 of 14 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
14
,
9
,
b
)
})
b
.
Run
(
"9 of 15 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
15
,
9
,
b
)
})
b
.
Run
(
"9 of 16 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
16
,
9
,
b
)
})
b
.
Run
(
"9 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
17
,
9
,
b
)
})
config
:=
benchConfig
()
b
.
Run
(
"9 of 9 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
9
,
9
,
b
)
})
b
.
Run
(
"9 of 10 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
10
,
9
,
b
)
})
b
.
Run
(
"9 of 11 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
11
,
9
,
b
)
})
b
.
Run
(
"9 of 12 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
12
,
9
,
b
)
})
b
.
Run
(
"9 of 13 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
13
,
9
,
b
)
})
b
.
Run
(
"9 of 14 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
14
,
9
,
b
)
})
b
.
Run
(
"9 of 15 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
15
,
9
,
b
)
})
b
.
Run
(
"9 of 16 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
16
,
9
,
b
)
})
b
.
Run
(
"9 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
17
,
9
,
b
)
})
}
func
BenchmarkTallyThreshold
(
b
*
testing
.
B
)
{
log
.
SetOutput
(
ioutil
.
Discard
)
b
.
Run
(
"9 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
17
,
9
,
b
)
})
b
.
Run
(
"10 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
17
,
10
,
b
)
})
b
.
Run
(
"11 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
17
,
11
,
b
)
})
b
.
Run
(
"12 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
17
,
12
,
b
)
})
b
.
Run
(
"13 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
17
,
13
,
b
)
})
b
.
Run
(
"14 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
17
,
14
,
b
)
})
b
.
Run
(
"15 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
17
,
15
,
b
)
})
b
.
Run
(
"16 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
17
,
16
,
b
)
})
b
.
Run
(
"17 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
17
,
17
,
b
)
})
config
:=
benchConfig
()
b
.
Run
(
"9 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
17
,
9
,
b
)
})
b
.
Run
(
"10 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
17
,
10
,
b
)
})
b
.
Run
(
"11 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
17
,
11
,
b
)
})
b
.
Run
(
"12 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
17
,
12
,
b
)
})
b
.
Run
(
"13 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
17
,
13
,
b
)
})
b
.
Run
(
"14 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
17
,
14
,
b
)
})
b
.
Run
(
"15 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
17
,
15
,
b
)
})
b
.
Run
(
"16 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
17
,
16
,
b
)
})
b
.
Run
(
"17 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
17
,
17
,
b
)
})
}
func
BenchmarkTallyOptimal
(
b
*
testing
.
B
)
{
log
.
SetOutput
(
ioutil
.
Discard
)
b
.
Run
(
"5 of 9 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
9
,
5
,
b
)
})
b
.
Run
(
"6 of 11 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
11
,
6
,
b
)
})
b
.
Run
(
"7 of 13 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
13
,
7
,
b
)
})
b
.
Run
(
"8 of 15 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
15
,
8
,
b
)
})
b
.
Run
(
"9 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
17
,
9
,
b
)
})
b
.
Run
(
"10 of 19 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
19
,
10
,
b
)
})
b
.
Run
(
"11 of 21 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
10
,
21
,
11
,
b
)
})
config
:=
benchConfig
()
b
.
Run
(
"5 of 9 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
9
,
5
,
b
)
})
b
.
Run
(
"6 of 11 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
11
,
6
,
b
)
})
b
.
Run
(
"7 of 13 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
13
,
7
,
b
)
})
b
.
Run
(
"8 of 15 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
15
,
8
,
b
)
})
b
.
Run
(
"9 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
17
,
9
,
b
)
})
b
.
Run
(
"10 of 19 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
19
,
10
,
b
)
})
b
.
Run
(
"11 of 21 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkTally
(
config
,
10
,
21
,
11
,
b
)
})
}
///////////////////////////////
...
...
@@ -189,19 +212,19 @@ func BenchmarkTallyOptimal(b *testing.B) {
///////////////////////////////
var
resultcombine
*
big
.
Int
func
benchmarkCombine
(
votecount
,
serverCount
,
reqServer
int
,
b
*
testing
.
B
)
{
func
benchmarkCombine
(
params
*
common
.
Params
,
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
)
ballots
:=
createAllBallots
(
votes
,
serverCount
,
reqServer
,
xs
,
params
)
ballotBoxes
:=
make
([]
*
BallotBox
,
serverCount
)
tallyBoxes
:=
make
([]
*
TallyBox
,
serverCount
)
for
i
:=
0
;
i
<
serverCount
;
i
++
{
tallyBoxes
[
i
]
=
NewTallyBox
(
common
.
DefaultP
arams
()
)
ballotBoxes
[
i
]
=
NewBallotBox
(
xs
[
i
],
common
.
DefaultParams
())
tallyBoxes
[
i
]
=
NewTallyBox
(
p
arams
)
ballotBoxes
[
i
]
=
NewBallotBox
(
xs
[
i
],
benchConfig
())
}
for
i
,
ballotbox
:=
range
ballotBoxes
{
...
...
@@ -233,41 +256,44 @@ func benchmarkCombine(votecount, serverCount, reqServer int, b *testing.B) {
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
)
})
config
:=
benchConfig
()
b
.
Run
(
"10 Votes"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
5
,
3
,
b
)
})
b
.
Run
(
"100 Votes"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
100
,
5
,
3
,
b
)
})
b
.
Run
(
"1000 Votes"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
1000
,
5
,
3
,
b
)
})
b
.
Run
(
"10000 Votes"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10000
,
5
,
3
,
b
)
})
b
.
Run
(
"100000 Votes"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
100000
,
5
,
3
,
b
)
})
}
func
BenchmarkCombineServer
(
b
*
testing
.
B
)
{
log
.
SetOutput
(
ioutil
.
Discard
)
b
.
Run
(
"15 of 15 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
15
,
15
,
b
)
})
b
.
Run
(
"15 of 16 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
16
,
15
,
b
)
})
b
.
Run
(
"15 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
17
,
15
,
b
)
})
b
.
Run
(
"15 of 18 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
18
,
15
,
b
)
})
b
.
Run
(
"15 of 19 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
19
,
15
,
b
)
})
b
.
Run
(
"15 of 20 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
20
,
15
,
b
)
})
b
.
Run
(
"15 of 21 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
21
,
15
,
b
)
})
b
.
Run
(
"15 of 22 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
22
,
15
,
b
)
})
b
.
Run
(
"15 of 23 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
23
,
15
,
b
)
})
b
.
Run
(
"15 of 24 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
24
,
15
,
b
)
})
b
.
Run
(
"15 of 25 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
25
,
15
,
b
)
})
b
.
Run
(
"15 of 26 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
26
,
15
,
b
)
})
b
.
Run
(
"15 of 27 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
27
,
15
,
b
)
})
b
.
Run
(
"15 of 28 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
28
,
15
,
b
)
})
b
.
Run
(
"15 of 29 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
29
,
15
,
b
)
})
config
:=
benchConfig
()
b
.
Run
(
"15 of 15 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
15
,
15
,
b
)
})
b
.
Run
(
"15 of 16 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
16
,
15
,
b
)
})
b
.
Run
(
"15 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
17
,
15
,
b
)
})
b
.
Run
(
"15 of 18 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
18
,
15
,
b
)
})
b
.
Run
(
"15 of 19 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
19
,
15
,
b
)
})
b
.
Run
(
"15 of 20 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
20
,
15
,
b
)
})
b
.
Run
(
"15 of 21 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
21
,
15
,
b
)
})
b
.
Run
(
"15 of 22 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
22
,
15
,
b
)
})
b
.
Run
(
"15 of 23 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
23
,
15
,
b
)
})
b
.
Run
(
"15 of 24 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
24
,
15
,
b
)
})
b
.
Run
(
"15 of 25 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
25
,
15
,
b
)
})
b
.
Run
(
"15 of 26 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
26
,
15
,
b
)
})
b
.
Run
(
"15 of 27 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
27
,
15
,
b
)
})
b
.
Run
(
"15 of 28 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
28
,
15
,
b
)
})
b
.
Run
(
"15 of 29 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
29
,
15
,
b
)
})
}
func
BenchmarkCombineThreshold
(
b
*
testing
.
B
)
{
log
.
SetOutput
(
ioutil
.
Discard
)
b
.
Run
(
"9 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
17
,
9
,
b
)
})
b
.
Run
(
"10 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
17
,
10
,
b
)
})
b
.
Run
(
"11 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
17
,
11
,
b
)
})
b
.
Run
(
"12 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
17
,
12
,
b
)
})
b
.
Run
(
"13 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
17
,
13
,
b
)
})
b
.
Run
(
"14 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
17
,
14
,
b
)
})
b
.
Run
(
"15 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
17
,
15
,
b
)
})
b
.
Run
(
"16 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
17
,
16
,
b
)
})
b
.
Run
(
"17 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
10
,
17
,
17
,
b
)
})
config
:=
benchConfig
()
b
.
Run
(
"9 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
17
,
9
,
b
)
})
b
.
Run
(
"10 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
17
,
10
,
b
)
})
b
.
Run
(
"11 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
17
,
11
,
b
)
})
b
.
Run
(
"12 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
17
,
12
,
b
)
})
b
.
Run
(
"13 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
17
,
13
,
b
)
})
b
.
Run
(
"14 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
17
,
14
,
b
)
})
b
.
Run
(
"15 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
17
,
15
,
b
)
})
b
.
Run
(
"16 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
17
,
16
,
b
)
})
b
.
Run
(
"17 of 17 servers"
,
func
(
b
*
testing
.
B
)
{
benchmarkCombine
(
config
,
10
,
17
,
17
,
b
)
})
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment