commit d279b3a6c37f98330f3ba6f1a5e75351d3204f13 Author: Karsten Loesing karsten.loesing@gmx.net Date: Mon Nov 26 16:38:55 2012 -0500
Add total excluded advertised bandwidth (#1854). --- task-1854/plot-entropy.R | 24 +++++++++++++++--------- task-1854/pyextract.py | 29 +++++++++++++++++++---------- 2 files changed, 34 insertions(+), 19 deletions(-)
diff --git a/task-1854/plot-entropy.R b/task-1854/plot-entropy.R index 34635e3..95b8b18 100644 --- a/task-1854/plot-entropy.R +++ b/task-1854/plot-entropy.R @@ -3,39 +3,45 @@ library(reshape) library(scales)
e <- read.csv("extracted.csv", header = FALSE, - col.names = c("validafter", "min_adv_bw", "relays", "linf", "graph"), - stringsAsFactor = FALSE) + col.names = c("validafter", "min_adv_bw", "relays", "linf", + "excl_adv_bw", "graph"), stringsAsFactor = FALSE)
l <- e[e$graph == 'last', ] -l <- data.frame(x = l$min_adv_bw, relays = l$relays, linf = l$linf) +l <- data.frame(x = l$min_adv_bw, relays = l$relays, + excladvbw = l$excl_adv_bw, linf = l$linf) l <- melt(l, "x") ggplot(l, aes(x = x, y = value)) + geom_line() + facet_grid(variable ~ ., scales = "free_y") + scale_x_log10(name = "\nAdvertised bandwidth cutoff in B/s (log scale)") + -scale_y_continuous(name = "") + +scale_y_continuous(name = paste("Number of relays, excluded advertised", + "bandwidth, or linf\n")) + opts(title = paste("Consensus with valid-after time ", max(e$validafter), "\n", sep = ""))
l <- e[e$graph == 'last', ] -l <- data.frame(x = l$min_adv_bw, relays = l$relays, linf = l$linf) +l <- data.frame(x = l$min_adv_bw, relays = l$relays, + excladvbw = l$excl_adv_bw, linf = l$linf) l <- melt(l, "x") ggplot(l, aes(x = x, y = value)) + geom_line() + facet_grid(variable ~ ., scales = "free_y") + scale_x_log10(name = "\nAdvertised bandwidth cutoff in B/s (log scale)") + -scale_y_log10(name = "Number of relays or linf (log scale)") + +scale_y_log10(name = paste("Number of relays, excluded advertised", + "bandwidth, or linf (log scale)\n")) + opts(title = paste("Consensus with valid-after time ", max(e$validafter), "\n", sep = ""))
l <- e[e$graph == 'last' & e$min_adv_bw >= 10000 & e$min_adv_bw <= 100000, ] -l <- data.frame(x = l$min_adv_bw, relays = l$relays, linf = l$linf) +l <- data.frame(x = l$min_adv_bw, relays = l$relays, + excladvbw = l$excl_adv_bw, linf = l$linf) l <- melt(l, "x") ggplot(l, aes(x = x, y = value)) + geom_line() + facet_grid(variable ~ ., scales = "free_y") + -scale_x_log10(name = "\nAdvertised bandwidth cutoff in B/s (log scale)") + -scale_y_continuous(name = "") + +scale_x_log10(name = "\nAdvertised bandwidth cutoff in B/s (zoomed, log scale)") + +scale_y_continuous(name = paste("Number of relays, excluded advertised", + "bandwidth, or linf\n")) + opts(title = paste("Consensus with valid-after time ", max(e$validafter), "\n", sep = ""))
diff --git a/task-1854/pyextract.py b/task-1854/pyextract.py index 4220a2a..33614e2 100644 --- a/task-1854/pyextract.py +++ b/task-1854/pyextract.py @@ -3,25 +3,34 @@ import sys
def main(): out_file = open('extracted.csv', 'w') - last_validafter = '' - last_lines = [] + prev_validafter, max_validafter = '', '' + max_lines = [] + prev_relays, prev_min_adv_bw = 0, 0 for line in open('entropy.csv'): parts = line.strip().split(',') validafter = parts[0] min_adv_bw = int(parts[1]) - relays = parts[2] + relays = int(parts[2]) linf = parts[3] - if last_validafter != validafter: - last_lines = [] + if validafter != prev_validafter: + prev_relays, prev_min_adv_bw, excluded_adv_bw = 0, 0, 0 next_cutoffs = [0, 10000, 20000, 30000, 40000, 50000, 75000, 100000, 100000000000000000000] + excluded_adv_bw += (prev_relays - relays) * prev_min_adv_bw + extended_line = "%s,%d" % (line.strip(), excluded_adv_bw, ) + if validafter > max_validafter: + max_validafter = validafter + max_lines = [] + if validafter == max_validafter: + max_lines.append(extended_line) while min_adv_bw >= next_cutoffs[0]: - out_file.write("%s,%d,%s,%s,history\n" % (validafter, - next_cutoffs[0], relays, linf, )) + out_file.write("%s,%d,%d,%s,%d,history\n" % (validafter, + next_cutoffs[0], relays, linf, excluded_adv_bw, )) next_cutoffs.pop(0) - last_lines.append(line.strip()) - last_validafter = validafter - for line in last_lines: + prev_validafter = validafter + prev_relays = relays + prev_min_adv_bw = min_adv_bw + for line in max_lines: out_file.write(line + ",last\n")
if __name__ == '__main__':