(self, node_thres, edge_thres)
Prune the profile
Prune the profile
Prune the profile
def prune(self, node_thres, edge_thres):
        """Prune the profile"""

        # compute the prune ratios
        for function in self.functions.itervalues():
            try:
                function.weight = function[TOTAL_TIME_RATIO]
            except UndefinedEvent:
                pass

            for call in function.calls.itervalues():
                callee = self.functions[call.callee_id]

                if TOTAL_TIME_RATIO in call:
                    # handle exact cases first
                    call.weight = call[TOTAL_TIME_RATIO] 
                else:
                    try:
                        # make a safe estimate
                        call.weight = min(function[TOTAL_TIME_RATIO], callee[TOTAL_TIME_RATIO]) 
                    except UndefinedEvent:
                        pass

        # prune the nodes
        for function_id in self.functions.keys():
            function = self.functions[function_id]
            if function.weight is not None:
                if function.weight < node_thres:
                    del self.functions[function_id]

        # prune the egdes
        for function in self.functions.itervalues():
            for callee_id in function.calls.keys():
                call = function.calls[callee_id]
                if callee_id not in self.functions or call.weight is not None and call.weight < edge_thres:
                    del function.calls[callee_id]
def prune ( self , node_thres , edge_thres ) : # compute the prune ratios for function in self . functions . itervalues ( ) : try : function . weight = function [ TOTAL_TIME_RATIO ] except UndefinedEvent : pass for call in function . calls . itervalues ( ) : callee = self . functions [ call . callee_id ] if TOTAL_TIME_RATIO in call : # handle exact cases first call . weight = call [ TOTAL_TIME_RATIO ] else : try : # make a safe estimate call . weight = min ( function [ TOTAL_TIME_RATIO ] , callee [ TOTAL_TIME_RATIO ] ) except UndefinedEvent : pass # prune the nodes for function_id in self . functions . keys ( ) : function = self . functions [ function_id ] if function . weight is not None : if function . weight < node_thres : del self . functions [ function_id ] # prune the egdes for function in self . functions . itervalues ( ) : for callee_id in function . calls . keys ( ) : call = function . calls [ callee_id ] if callee_id not in self . functions or call . weight is not None and call . weight < edge_thres : del function . calls [ callee_id ]