123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #!/usr/bin/env python3
- """Compute the core-time tradeoff given the experimental results for
- the token and ID channels"""
- import sys
- import csv
- import math
- if len(sys.argv)!=3:
- print(f"Usage: {sys.argv[0]} <token-channel.csv file> <id-channel.csv file>")
- sys.exit(0)
- token_file = open(sys.argv[1], 'r')
- id_file = open(sys.argv[2], 'r')
- token_input = csv.DictReader(token_file)
- id_input = csv.DictReader(id_file)
- token_data = sorted(
- filter(lambda row: row['T']=='1' and row['N']=='1048576', token_input),
- key = lambda row: (int(row['T']), int(row['M']), int(row['N'])))
- id_data = sorted(
- filter(lambda row: row['T']=='1' and row['N']=='1048576', id_input),
- key = lambda row: (int(row['T']), int(row['M']), int(row['N'])))
- token_times = [ ( int(row['M']),
- float(row['epoch_mean']) + float(row['bytes_max'])*8/13000000000,
- float(row['wn_mean']) ) for row in token_data ]
- id_times = [ ( int(row['M']),
- float(row['epoch_mean']) + float(row['bytes_max'])*8/13000000000,
- float(row['wn_mean']) ) for row in id_data ]
- # Sort the list of all times appearing in the data
- all_times = sorted([ tpl[1] for tpl in token_times + id_times ])
- # Put integer times in there as well
- max_int_time = int(all_times[-1])
- all_times = sorted(all_times + [t for t in range(1,max_int_time+1)])
- # Interpolate 4 points between each pair of points in the sorted list
- # and flatten the result
- interp_times = [ x for xs in
- [[all_times[j] + i/5*(all_times[j+1]-all_times[j])
- for i in range(5)] for j in range(len(all_times)-1)]
- for x in xs ] + [ all_times[-1] ]
- for target_time in interp_times:
- # Find the smallest public and private channel configurations that
- # are at or below the target time
- try:
- token_conf = next(filter(lambda tpl: tpl[1] <= target_time, token_times))
- id_conf = next(filter(lambda tpl: tpl[1] <= target_time, id_times))
- token_cores = math.ceil((1 + token_conf[2] / target_time) * token_conf[0])
- id_cores = math.ceil((1 + id_conf[2] / target_time) * id_conf[0])
- print (target_time, token_conf[0], id_conf[0], token_cores,
- id_cores, token_cores + id_cores)
- except:
- # One of the channels couldn't reach a time as small as the
- # other channel could
- pass
|