diff options
| author | thibauth <thibauth@30fcff6e-8de6-41c7-acce-77ff6d1dd07b> | 2011-07-01 15:31:22 +0000 |
|---|---|---|
| committer | thibauth <thibauth@30fcff6e-8de6-41c7-acce-77ff6d1dd07b> | 2011-07-01 15:31:22 +0000 |
| commit | 33a91e96084bdbfc4403e0a7d5a8ccc3c022287d (patch) | |
| tree | 3bcc4f4f0331d540bc5a69b4da9936f31dbafc60 | |
| parent | 1bc4b7d7b988976d37a05c1c7a8348fb92985400 (diff) | |
| download | pacemaker-33a91e96084bdbfc4403e0a7d5a8ccc3c022287d.tar.gz | |
More stats
git-svn-id: https://scm.gforge.inria.fr/svn/pacemaker@37 30fcff6e-8de6-41c7-acce-77ff6d1dd07b
| -rw-r--r-- | sources/thibaut/globals.ml | 19 | ||||
| -rw-r--r-- | sources/thibaut/plot.py | 14 | ||||
| -rw-r--r-- | sources/thibaut/simulator.ml | 5 |
3 files changed, 29 insertions, 9 deletions
diff --git a/sources/thibaut/globals.ml b/sources/thibaut/globals.ml index 9f8f3a0..450c1c8 100644 --- a/sources/thibaut/globals.ml +++ b/sources/thibaut/globals.ml @@ -249,11 +249,24 @@ type peer = { } and slot = peer SlotArray.slot +let winners = ref 0 +let nsessions = ref 0 +let test = ref 0 + let disconnect oc round peer = SlotArray.clear peer.slots; - if (round-peer.connection_time) > 0 then - Printf.fprintf oc "%d %d %d\n%!" peer.id (round-peer.connection_time) - peer.nproofs; + let duration = round - peer.connection_time in + if duration > 0 then begin + Printf.fprintf oc "%d %d %d\n%!" peer.id + duration peer.nproofs; + if duration > 20 then begin + incr nsessions; + if peer.nproofs >= duration/10 - 1 then + incr winners; + if (float_of_int duration)/.10. -. (float_of_int peer.nproofs) >= 0.5 then + incr test + end + end; peer.con_state <- OFF; peer.distance <- -1; peer.nproofs <- 0 diff --git a/sources/thibaut/plot.py b/sources/thibaut/plot.py index 92e5fcd..3900b65 100644 --- a/sources/thibaut/plot.py +++ b/sources/thibaut/plot.py @@ -13,7 +13,7 @@ plt.savefig(os.path.join(dirname, "rounds.png"))""" plt.cla() sessions = os.path.join(dirname, "sessions.data") a = np.loadtxt(sessions) -plt.hist(a, bins=100) +plt.hist(a, bins=100, log = True) plt.savefig(os.path.join(dirname, "sessions.png")) plt.cla() @@ -22,7 +22,13 @@ a = np.loadtxt(avail) plt.hist(a, bins=100,range=(0,1)) plt.savefig(os.path.join(dirname, "avail.png")) +plt.cla() simul_sessions = os.path.join(dirname, "simul_sessions.data") -a,b = np.loadtxt(simul_sessions, unpack=True, usecols = (1,2)) -c = np.unique(np.floor(a/10)) -print np.sum(np.floor(a/10))/np.sum(b) +duration, proofs = np.loadtxt(simul_sessions, unpack = True, usecols=(1,2)) +result = np.zeros((len(duration)+1,2)) +for i in range(len(duration)): + temp = duration[i] + result[temp,0] = result[temp,0] + proofs[i] + result[temp,1] = result[temp,1] + 1 +plt.plot(result[:200,0]/result[:200,1]) +plt.show() diff --git a/sources/thibaut/simulator.ml b/sources/thibaut/simulator.ml index 52cc047..12d5bfb 100644 --- a/sources/thibaut/simulator.ml +++ b/sources/thibaut/simulator.ml @@ -83,7 +83,7 @@ let peers = Array.init npeers history = RoundMap.empty; distance = -1; connection_time = 0; - nproofs = 1 + nproofs = 0 } in p ) @@ -153,5 +153,6 @@ let _ = end done; print_newline (); - + Printf.printf "%f %f\n" ((float_of_int !winners)/.(float_of_int !nsessions)) + ((float_of_int !test)/.(float_of_int !nsessions)) |
