assert table_is_subset_of(table, new_table) sys.stdout.write( "\033[{}m{:4d}\033[39m\t{:.2f}%\n".format( 32 if len(new_table) < 1024 else 31, len(new_table), 100.0 * float(len(table) - len(new_table)) / len(table) ) ) return chip, new_table if __name__ == "__main__": # Parse the arguments parser = argparse.ArgumentParser() parser.add_argument("routing_table") parser.add_argument("out") args = parser.parse_args() # Load and minimise all routing tables print("Loading routing tables...") with open(args.routing_table, "rb") as f: uncompressed = common.read_routing_tables(f) print("Minimising routing tables...") compressed = dict(my_minimize(chip, table) for chip, table in iteritems(uncompressed)) fn = args.out print("Dumping minimised routing tables to {}...".format(fn)) with open(fn, "wb+") as f: common.dump_routing_tables(f, compressed)
def my_minimize(chip, table): print("Minimising {}, {} entries...".format(chip, len(table))) t = time.clock() table, _ = ordered_covering(table, None) total = time.clock() - t print("... to {} entries in {} s".format(len(table), total)) return chip, table if __name__ == "__main__": # Parse the arguments parser = argparse.ArgumentParser() parser.add_argument("routing_table") parser.add_argument("output") args = parser.parse_args() # Load and minimise all routing tables print("Loading routing tables...") with open(args.routing_table, "rb") as f: uncompressed = common.read_routing_tables(f) print("Minimising routing tables...") compressed = dict( my_minimize(chip, table) for chip, table in iteritems(uncompressed)) print("Dumping minimised routing tables to {}...".format(args.output)) with open(args.output, "wb+") as f: common.dump_routing_tables(f, compressed)
import argparse import common from rig.routing_table import table_is_subset_of from six import iteritems import sys if __name__ == "__main__": # Parse the arguments parser = argparse.ArgumentParser() parser.add_argument("original_table") parser.add_argument("compressed_table") args = parser.parse_args() # Load and test all routing tables print("Loading...") with open(args.original_table, "rb") as f: original = common.read_routing_tables(f) with open(args.compressed_table, "rb") as f: compressed = common.read_routing_tables(f) print("Testing...") for chip, table in iteritems(original): print("\t{}".format(chip)) assert table_is_subset_of(table, compressed[chip])