forked from ron-rivest/audit-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scalability_test.py
70 lines (48 loc) · 1.4 KB
/
scalability_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# test_scalability.py
# Ronald L. Rivest with Huasyn Karimi
import syn2
import time
import structure
def tester(se):
# copy code here from syn2.test; modify as needed
se.seed = 9
syn2.generate_election_structure(se)
structure.finish_election_structure(se)
syn2.generate_contests(se)
syn2.generate_contest_groups(se)
syn2.generate_collections(se)
syn2.generate_reported(se)
syn2.generate_ballot_manifest(se)
syn2.generate_audited_votes(se)
for key in sorted(vars(se)):
print(key)
print(" ", vars(se)[key])
print("Checking structure:", structure.check_election_structure(se))
syn2.write_structure_csvs(se)
syn2.write_reported(se)
syn2.write_audit(se)
def scale_test(k):
"""
For various values of k = 3, 4, ...
generate an election with
10**k voters
10**(k-3) pbcids
10**(k-2) cids
10 selids / cid
"""
# start timer
start = time.time()
# ... set parameters here based on k
se = syn2.SynElection()
se.min_n_bids_per_pbcid = 10**3
se.max_n_bids_per_pbcid = 10**3
se.n_pbcids = 10**(k-3)
se.min_n_selids_per_cid = 10
se.max_n_selids_per_cid = 10
# run "test"
tester(se)
# stop timer; print k and elapsed time
end = time.time()
print("For k=", k, ",", end-start, "seconds elapsed.")
for k in range(3, 8):
scale_test(k)