def handle_summary(self): self._call_map = {} for f in self.get_frames(): self._call_map[f.get("cfg_id")] = set([]) targeted_calls = self._cfg_tree.xpath("/Project/Method/Block/Call/Getattr/Target[@cfg_id]|"+ "/Project/Method/Block/Call/Direct/Target[@cfg_id]|"+ "/Project/Function/Block/Call/Getattr/Target[@cfg_id]|"+ "/Project/Function/Block/Call/Direct/Target[@cfg_id]") for call in targeted_calls: source = call.getparent().getparent().getparent().getparent().get("cfg_id") self._call_map[source].add(call.get("cfg_id")) self._call_map[call.get("cfg_id")].add(source) rec_depth = sys.getrecursionlimit() sys.setrecursionlimit(len(self._call_map.keys())) subtrees = graph_connected_components(self._call_map) sys.setrecursionlimit(rec_depth) subtree_sizes = [len(s) for s in subtrees] print "Processed",self._input_xml print "Number of frames",len(self._call_map.keys()) print "Number of functional trees ",len(subtrees) print "Max functional tree size ", numpy.max(subtree_sizes) print "Min functional tree size ", numpy.min(subtree_sizes) print "Avg functional tree size ", numpy.average(subtree_sizes) print "Median functional tree size ", numpy.median(subtree_sizes) print "Variance functional tree size ", numpy.var(subtree_sizes) print "Standard deviation functional tree size ", numpy.std(subtree_sizes)
def handle_summary(self): class_ids = set([c.get("id") for c in self._classes]) subtrees = [] max_size = 0 length = 0 subtree_sizes = [] class_num = len(class_ids) subtree_num=1 adj_map = {} for c_id in class_ids: adj_map[c_id] = set([]) for c in self._classes: parents = self.get_parents(c) adj_map[c.get("id")] |= set([p.get("id") for p in parents]) for p in parents: adj_map[p.get("id")].add(c.get("id")) subtrees = graph_connected_components(adj_map) subtree_sizes = [len(s) for s in subtrees] print "Input file -",self._in_file print "Number of classes ",class_num print "Number of inheritance trees ",len(subtrees) print "Max inheritance tree size ", numpy.max(subtree_sizes) print "Min inheritance tree size ", numpy.min(subtree_sizes) print "Avg inheritance tree size ", numpy.average(subtree_sizes) print "Median inheritance tree size ", numpy.median(subtree_sizes) print "Variance inheritance tree size ", numpy.var(subtree_sizes) print "Standard deviation inheritance tree size ", numpy.std(subtree_sizes)