summaryrefslogtreecommitdiff log msg author committer range
diff options
 context: 12345678910152025303540 space: includeignore mode: unifiedssdiffstat only
author committer ng0 2018-03-05 07:56:12 +0000 ng0 2018-03-05 07:56:12 +0000 66e6d0281c2247e9324be24a34802e09e79a6b0e (patch) 46c624ceabc6fa076081d405862b4b4b701b65d5 /src/consensus/consensus-simulation.py 859222c9a2844340731b4c4e057b6c6d44442528 (diff)
futures
Diffstat (limited to 'src/consensus/consensus-simulation.py')
-rw-r--r--src/consensus/consensus-simulation.py7
1 files changed, 6 insertions, 1 deletions
 diff --git a/src/consensus/consensus-simulation.py b/src/consensus/consensus-simulation.pyindex 19b636cbd..542fe0dac 100644--- a/src/consensus/consensus-simulation.py+++ b/src/consensus/consensus-simulation.py@@ -17,10 +17,13 @@ # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, # Boston, MA 02110-1301, USA. +from __future__ import absolute_import+from __future__ import print_function import argparse import random from math import ceil,log,floor + def bsc(n): """ count the bits set in n""" l = n.bit_length()@@ -32,6 +35,7 @@ def bsc(n): x = x << 1 return c + def simulate(k, n, verbose): assert k < n largest_arc = int(2**ceil(log(n, 2))) / 2@@ -87,6 +91,7 @@ def simulate(k, n, verbose): random.shuffle(peers) return rounds + if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("k", metavar="k", type=int, help="#(bad peers)")@@ -98,6 +103,6 @@ if __name__ == "__main__": sum = 0.0; for n in xrange (0, args.r): sum += simulate(args.k, args.n, args.verbose)- print sum / args.r;+ printsum / args.r;