def __getDiagramLayout(self): " Runs external tools to get the diagram layout " # Preparation: build a map of func ID -> fileName + line funcMap = {} index = 0 for func, props in self.__stats.stats.items(): funcMap[index] = (func[0], func[1]) index += 1 # First step is to run grpof2dot gprof2dot = thirdpartyDir + "gprof2dot" + os.path.sep + "gprof2dot.py" outputFile = self.__dataFile + ".dot" nodeLimit = Settings().profileNodeLimit edgeLimit = Settings().profileEdgeLimit dotSpec = safeRun([ gprof2dot, '-n', str(nodeLimit), '-e', str(edgeLimit), '-f', 'pstats', '-o', outputFile, self.__dataFile ]) graphDescr = safeRun(["dot", "-Tplain", outputFile]) graph = getGraphFromPlainDotData(graphDescr) graph.normalize(self.physicalDpiX(), self.physicalDpiY()) self.__scene.clear() self.__scene.setSceneRect(0, 0, graph.width, graph.height) for edge in graph.edges: self.__scene.addItem(FuncConnection(edge)) if edge.label != "": self.__scene.addItem(FuncConnectionLabel(edge)) for node in graph.nodes: fileName = "" lineNumber = 0 isOutside = True nodeID, newLabel = extractNodeID(node.label) if nodeID != -1: node.label = newLabel # Now, detect the file name/line number and # if it belongs to the project (fileName, lineNumber) = funcMap[nodeID] self.__scene.addItem( Function(node, fileName, lineNumber, self.__isOutsideItem(fileName))) return
def __getDiagramLayout( self ): " Runs external tools to get the diagram layout " # Preparation: build a map of func ID -> fileName + line funcMap = {} index = 0 for func, props in self.__stats.stats.items(): funcMap[ index ] = ( func[ 0 ], func[ 1 ] ) index += 1 # First step is to run grpof2dot gprof2dot = thirdpartyDir + "gprof2dot" + os.path.sep + "gprof2dot.py" outputFile = self.__dataFile + ".dot" nodeLimit = Settings().profileNodeLimit edgeLimit = Settings().profileEdgeLimit dotSpec = safeRun( [ gprof2dot, '-n', str( nodeLimit ), '-e', str( edgeLimit ), '-f', 'pstats', '-o', outputFile, self.__dataFile ] ) graphDescr = safeRun( [ "dot", "-Tplain", outputFile ] ) graph = getGraphFromPlainDotData( graphDescr ) graph.normalize( self.physicalDpiX(), self.physicalDpiY() ) self.__scene.clear() self.__scene.setSceneRect( 0, 0, graph.width, graph.height ) for edge in graph.edges: self.__scene.addItem( FuncConnection( edge ) ) if edge.label != "": self.__scene.addItem( FuncConnectionLabel( edge ) ) for node in graph.nodes: fileName = "" lineNumber = 0 isOutside = True nodeID, newLabel = extractNodeID( node.label ) if nodeID != -1: node.label = newLabel # Now, detect the file name/line number and # if it belongs to the project ( fileName, lineNumber ) = funcMap[ nodeID ] self.__scene.addItem( Function( node, fileName, lineNumber, self.__isOutsideItem( fileName ) ) ) return
def getGraphFromDescrptionFile(fName): " Runs dot and then parses and builds normalized graph " return getGraphFromPlainDotData(safeRun(["dot", "-Tplain", fName]))