Commit 2bbfe85c authored by Matt Traudt's avatar Matt Traudt
Browse files

Add option to skip scaling the bw values

parent 82f5ac1d
......@@ -64,13 +64,16 @@ def warn_if_not_accurate_enough(lines, constant):
round(margin*100, 2)), file=sys.stderr)
def scale_lines(v3bw_lines, scale_constant):
scale = len(v3bw_lines) * scale_constant
def scale_lines(args, v3bw_lines):
total = sum([ for l in v3bw_lines])
if not args.raw:
scale = len(v3bw_lines) * args.scale_constant
scale = total
ratio = scale / total
for line in v3bw_lines: = round( * ratio)
warn_if_not_accurate_enough(v3bw_lines, scale_constant) = round( * ratio) + 1
warn_if_not_accurate_enough(v3bw_lines, args.scale_constant)
return v3bw_lines
......@@ -84,6 +87,9 @@ def gen_parser(sub):
p.add_argument('--scale-constant', default=7500, type=int,
help='When scaling bw weights, scale them using this const '
'multiplied by the number of measured relays')
p.add_argument('--raw', '--no-scale', action='store_true',
help='If specified, use bandwidth values as they are, with '
'no scaling')
def main(args, log_):
......@@ -104,7 +110,7 @@ def main(args, log_):
data = read_result_file(fname, data)
data_lines = [result_data_to_v3bw_line(data, fp) for fp in data]
data_lines = sorted(data_lines, key=lambda d:, reverse=True)
data_lines = scale_lines(data_lines, args.scale_constant)
data_lines = scale_lines(args, data_lines)
with open(args.output, 'wt') as fd:
for line in data_lines:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment