def data_by_numtyped(fname, pred=None): # Group data into a list of lists. # Index = Number of typed modules data = [[] for _ in range(1+util.count_modules(fname))] with open(fname, "r") as f: next(f) for line in f: cols = line.strip().split() title, vals = cols[0], cols[1:] if pred is None or pred(title): data[num_typed(title)].append([int(x) for x in vals]) return data
def main(fname): # Generate all edge combinations, # make all the graphs num_modules = util.count_modules(fname) edges = util.infer_edges(fname) if edges is None: print("Error: could not find graph file for '%s'" % fname) return ## All combos that are reasonably small for group_size in range(1, min(4, len(edges))): for edge_list in itertools.combinations(edges, group_size): make_plot(fname, edge_list) return
[i + 1 - 0.25, data[i]["ci"][0]], 0.5, data[i]["ci"][1] - data[i]["ci"][0], facecolor="royalblue" ) ax1.add_patch(ci_rect) plt.plot(i + 1, [data[i]["mean"]], color="w", marker="*", markeredgecolor="k") ## Save graph plt.xticks(range(1, 1 + len(data)), range(0, len(data))) # plt.yticks([5000,10000,15000]) #funkytown plt.yticks([100 * i for i in range(4, 10)]) ax1.yaxis.grid(True, linestyle="-", which="major", color="lightgrey", alpha=0.5) ax1.set_axisbelow(True) ax1.set_title(fname.rsplit("/", 1)[-1].rsplit(".")[0]) ax1.set_xlabel("Num. Typed Modules") ax1.set_ylabel("Runtime (ms)") new_name = util.gen_name(fname, "sampling-%s" % num_samples, "png") plt.savefig(new_name) plt.clf() print("Saved results to '%s'" % new_name) return if __name__ == "__main__": if len(sys.argv) == 2 and sys.argv[1].endswith(".tab"): fname = sys.argv[1] num_mods = util.count_modules(fname) if num_mods >= MIN_MODULES: main(fname, num_mods) else: print("Error: too few modules to sample. Need at least %s" % MIN_MODULES) else: print("Usage: sampling.py FILE.tab")