diff options
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/scripts/analyze-project-deps.py | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/lldb/scripts/analyze-project-deps.py b/lldb/scripts/analyze-project-deps.py index 1f7b5f393b9..2320100e4d1 100644 --- a/lldb/scripts/analyze-project-deps.py +++ b/lldb/scripts/analyze-project-deps.py @@ -1,6 +1,8 @@ import argparse +import itertools import os import re +import sys from use_lldb_suite import lldb_root @@ -22,7 +24,7 @@ src_map = {} include_regex = re.compile('#include \"((lldb|Plugins|clang)(.*/)+).*\"') def is_sublist(small, big): - it = iter(big)
+ it = iter(big) return all(c in it for c in small) def normalize_host(str): @@ -102,9 +104,7 @@ def expand(path_queue, path_lengths, cycles, src_map): continue next_len = path_lengths.pop(0) + 1 - last_component = cur_path[-1] - for item in src_map[last_component]: if item.startswith("clang"): continue @@ -143,6 +143,19 @@ for (path, deps) in items: for dep in sorted_deps: print "\t{}".format(dep[0]) +def iter_cycles(cycles): + global src_map + for cycle in cycles: + cycle.append(cycle[0]) + zipper = list(zip(cycle[0:-1], cycle[1:])) + result = [(x, src_map[x][y], y) for (x,y) in zipper] + total = 0 + smallest = result[0][1] + for (first, value, last) in result: + total += value + smallest = min(smallest, value) + yield (total, smallest, result) + if args.discover_cycles: print "Analyzing cycles..." @@ -151,8 +164,18 @@ if args.discover_cycles: average = sum([len(x)+1 for x in cycles]) / len(cycles) print "Found {} cycles. Average cycle length = {}.".format(len(cycles), average) - for cycle in cycles: - cycle.append(cycle[0]) - print " -> ".join(cycle) - + if args.show_counts: + counted = list(iter_cycles(cycles)) + counted.sort(lambda A, B: cmp(A[0], B[0])) + for (total, smallest, cycle) in counted: + sys.stdout.write("{} deps to break: ".format(total)) + sys.stdout.write(cycle[0][0]) + for (first, count, last) in cycle: + sys.stdout.write(" [{}->] {}".format(count, last)) + sys.stdout.write("\n") + else: + for cycle in cycles: + cycle.append(cycle[0]) + print " -> ".join(cycle) + sys.stdout.flush() pass
\ No newline at end of file |