You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
\subsection{Processing Time and Memory Consumption}
186
+
Clearly the most processing intesive task of the update mechanism
187
+
is the tally phase. It is the phase where all the collected votes
188
+
are counted in order to reach at a decision for a specific proposal.
189
+
190
+
We start with a theoretical time complexity analysis where we
191
+
assume a worst-case scenario, where we have $n$ participants that all
192
+
of them vote by submiting a single vote. Also we assume that we have
193
+
a single proposal, so that within a voting period, the number $n$ of participants coincides to the number of submitted ballots.
194
+
195
+
In the following we try to break up the operations during the tally phase.
196
+
In the heart of the tally phase lies the following function call,
197
+
which is called for each proposal.
198
+
199
+
\begin{lstlisting}[language=Haskell, caption=Tally phase initial function call]
200
+
tallyStake confidence result ballot stakeDistribution adversarialStakeRatio =
201
+
if stakeThreshold adversarialStakeRatio (totalStake stakeDistribution)
202
+
<
203
+
stakeOfKeys votingKeys stakeDistribution
204
+
then Just result
205
+
else Nothing
206
+
where
207
+
votingKeys = Map.filter (== confidence) ballot
208
+
\end{lstlisting}
209
+
210
+
\lstinline{Map.filter} \footnote{\href{url}{http://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Map-Strict.html\#g:25}}, is $O(n)$ so \lstinline{votingKeys} is $O(n)$, where $n$ is the number of ballots,
211
+
which as we have said coincides to the number of participants. At
212
+
this point, we have a single pass (loop) over $n$ ballots.
213
+
214
+
Furthermore, \lstinline{stakeOfKeys} makes the following calls:
The $intersection$ function in the worst-case is $O(n)$\footnote{\href{url}{http://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Map-Strict.html\#v:intersection}}. Therefore this is a second pass
225
+
(loop) over the data of length $n$.
226
+
\lstinline{foldl} is also $O(n)$\footnote{\href{url}{http://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Map-Strict.html\#v:foldl}}. This is a third pass (loop) over the data of
227
+
length $n$. Thus from the above analysis we see that we have for
228
+
a single proposal a call of \lstinline{tallyStake}, where in each
229
+
such call we have three passes over the data of length $n$. So in total
230
+
for a single proposal we do $3$ passes over the data of length $n$.
231
+
That is $3n$ operations, which means that the tally time
232
+
complexity is $O(n)$.
233
+
234
+
This result is also confirmed by the experimental evaluation
235
+
shown in the graph below:
236
+
237
+
\begin{figure}[htp]
238
+
\centering
239
+
240
+
\begin{tikzpicture}
241
+
\begin{axis}[
242
+
title={Elapsed time (sec) vs Number of participants},
0 commit comments