The trunk (leoGlobals.py) now contains a different kind of trace facility. It records the dynamic call graph, with counts. The graph is presented like this:
n calling function n called function1 n called function2 The 'n' for the calling function is the *total* number of times the function was called. The 'n' for the called functions are the number of times the called functions were called by the calling function. The graph isn't presented visually: you have to infer the links. Imo, the presentation is more useful than pycallgraph provides. To start tracing, do: tt = g.startTracer() To end tracing, do: tt.stop() Ending the trace prints the stats to the console. Here are the results of tracing leoAtFile.readAll when loading test.leo: callDict... 21 Tkinter.update_idletasks 3 _Pmw.Pmw_1_3.lib.PmwBase.__call__ 3 _Pmw.Pmw_1_3.lib.PmwBase.__call__ 2 Tkinter.set 1 leoTkinterFrame.setCallback 14 _Pmw.Pmw_1_3.lib.PmwNoteBook.selectpage 14 _Pmw.Pmw_1_3.lib.PmwBase.cget 14 _Pmw.Pmw_1_3.lib.PmwNoteBook.getcurselection 14 _Pmw.Pmw_1_3.lib.PmwNoteBook.index 7 g.ecnl 7 g.ecnls 7 g.ecnls 7 g.enl 7 g.enl 7 leoTkinterFrame.putnl 7 g.es 21 g.choose 7 g.ecnl 7 g.translateArgs 7 leoTkinterFrame.put 14 g.getBaseDirectory 14 g.os_path_isabs 38 g.get_directives_dict 28 g.skip_c_id 268 g.skip_line 285 g.is_special 3802 g.match_word 3802 g.skip_line 5348 g.match 5323 string.find 3866 g.match_word 35 g.isWordChar 14 g.os_path_dirname 28 g.toUnicodeFileEncoding 14 ntpath.dirname 14 g.os_path_exists 14 g.toUnicodeFileEncoding 14 ntpath.exists 32 g.os_path_isabs 32 g.toUnicodeFileEncoding 32 ntpath.isabs 21 g.os_path_join 63 g.toUnicodeFileEncoding 21 ntpath.join 7 g.os_path_normpath 14 g.toUnicodeFileEncoding 7 ntpath.normpath 1 g.scanAtTabwidthDirective 1 g.skip_long 9 g.set_delims_from_language 9 g.set_delims_from_string 9 g.set_delims_from_string 15 g.is_nl 16 g.is_ws 9 g.match_word 10 g.skip_ws 20 string.replace 2 g.set_language 2 g.match_word 2 g.set_delims_from_language 2 g.skip_c_id 2 g.skip_ws 2 string.lower 235 g.skip_c_id 1196 g.isWordChar 537 g.skip_id 1641 g.isWordChar 537 g.toUnicode 4070 g.skip_line 4070 string.find 1 g.skip_long 1 g.skip_ws 181 g.skip_to_char 181 string.find 2473 g.skip_ws 12760 g.is_ws 3926 g.toUnicode 63 encodings.cp1252.decode 151 g.toUnicodeFileEncoding 151 g.toUnicode 7 g.translateArgs 7 g.translateString 7 g.translateString 7 gettext.gettext 7 gettext._expand_lang 7 locale.normalize 7 gettext.dgettext 7 gettext.translation 7 gettext.find 7 gettext._expand_lang 28 os.get 7 gettext.gettext 7 gettext.dgettext 7 gettext.translation 7 gettext.find 7 leoAtFile.completeFirstDirectives 10 g.match 7 leoAtFile.completeLastDirectives 7 g.match 7 leoAtFile.copyAllTempBodyStringsToTnodes 7 leoNodes.__iter__ 77 leoNodes.bodyString 128 leoNodes.isDirty 84 leoNodes.next 7 leoNodes.self_and_subtree_iter 64 leoNodes.setBodyString 67 leoAtFile.createThinChild4 126 leoNodes.__init__ 63 leoNodes._linkAsNthChild 337 leoNodes.areEqual 63 leoNodes.numberOfChildren 67 leoNodes.scanGnx 67 leoNodes.setVisited 10 leoAtFile.findChild4 10 leoNodes.setVisited 7 leoAtFile.initCommonIvars 7 g.getOutputNewline 7 leoAtFile.initReadIvars 7 leoAtFile.initCommonIvars 7 leoAtFile.scanDefaultDirectory 7 leoAtFile.openFileForReading 7 g.os_path_join 7 g.os_path_normpath 7 leoAtFile.openForRead 7 leoAtFile.parseLeoSentinel 20 g.is_nl 10 g.is_ws 45 g.match 14 g.skip_ws 7 leoAtFile.read 7 g.es 7 leoAtFile.copyAllTempBodyStringsToTnodes 7 leoAtFile.initReadIvars 7 leoAtFile.openFileForReading 7 leoAtFile.readOpenFile 7 leoAtFile.scanAllDirectives 7 leoCommands.all_unique_tnodes_iter 14 leoNodes.__iter__ 7 leoNodes.anyAtFileNodeName 7 leoNodes.clearDirty 7 leoNodes.clearVisitedInTree 7 leoNodes.headString 7 leoNodes.isAnyAtFileNode 77 leoNodes.isVisited 2479 leoNodes.next 7 leoNodes.self_and_subtree_iter 0 leoAtFile.readAll 1 g.stop 7 leoAtFile.read 1 leoCommands.all_unique_vnodes_iter 1 leoCommands.nullPosition 1 leoNodes.__iter__ 286 leoNodes.__nonzero__ 350 leoNodes.clearOrphan 1 leoNodes.copy 281 leoNodes.isAtAutoNode 281 leoNodes.isAtFileNode 285 leoNodes.isAtIgnoreNode 278 leoNodes.isAtRawFileNode 285 leoNodes.isAtThinFileNode 285 leoNodes.isEqual 3 leoNodes.isOrphan 7 leoNodes.moveToNodeAfterTree 278 leoNodes.moveToThreadNext 351 leoNodes.next 9 leoAtFile.readDirective 9 g.match 18 g.match_word 3 leoAtFile.readEndAt 3 leoAtFile.popSentinelStack 3 leoAtFile.readLastDocLine 7 leoAtFile.readEndLeo 7 leoAtFile.readLine 77 leoAtFile.readEndNode 77 g.toUnicode 77 leoAtFile.popSentinelStack 1 leoNodes.__getattr__ 11 leoNodes.bodyString 77 leoNodes.hasBody 77 leoNodes.setVisited 8 leoAtFile.readEndOthers 8 leoAtFile.popSentinelStack 3 leoAtFile.readLastDocLine 3 g.match 1727 leoAtFile.readLine 1727 g.readlineForceUnixNewline 1727 g.toUnicode 11 leoAtFile.readNl 11 g.match 14 leoAtFile.readNonl 14 g.match 1482 leoAtFile.readNormalLine 60 g.match 1452 g.removeLeadingWhitespace 30 g.skip_ws 7 leoAtFile.readOpenFile 7 leoAtFile.completeFirstDirectives 7 leoAtFile.completeLastDirectives 7 leoAtFile.scanHeader 7 leoAtFile.scanText4 7 leoNodes.__nonzero__ 7 leoNodes.setVisited 11 leoAtFile.readRef 11 g.match 11 g.skip_ws 3 leoAtFile.readStartAt 3 g.match 3 g.skip_ws 77 leoAtFile.readStartNode 77 g.match 77 g.skip_leading_ws_with_indent 67 leoAtFile.createThinChild4 10 leoAtFile.findChild4 8 leoAtFile.readStartOthers 8 g.match 8 g.skip_ws 7 leoAtFile.scanAllDirectives 7 g.choose 7 g.getBaseDirectory 7 g.getOutputNewline 19 g.get_directives_dict 7 g.os_path_dirname 7 g.os_path_exists 9 g.os_path_isabs 7 g.os_path_join 1 g.scanAtTabwidthDirective 7 g.set_delims_from_language 2 g.set_language 7 leoNodes.__iter__ 7 leoNodes.anyAtFileNodeName 26 leoNodes.next 7 leoNodes.self_and_parents_iter 7 leoAtFile.scanDefaultDirectory 7 g.choose 7 g.getBaseDirectory 19 g.get_directives_dict 7 g.os_path_dirname 7 g.os_path_exists 9 g.os_path_isabs 7 g.os_path_join 7 leoNodes.__iter__ 7 leoNodes.anyAtFileNodeName 26 leoNodes.next 7 leoNodes.self_and_parents_iter 7 leoAtFile.scanHeader 7 leoAtFile.parseLeoSentinel 10 leoAtFile.readLine 7 leoAtFile.scanText4 9 leoAtFile.readDirective 3 leoAtFile.readEndAt 7 leoAtFile.readEndLeo 77 leoAtFile.readEndNode 8 leoAtFile.readEndOthers 1710 leoAtFile.readLine 11 leoAtFile.readNl 14 leoAtFile.readNonl 1482 leoAtFile.readNormalLine 11 leoAtFile.readRef 3 leoAtFile.readStartAt 77 leoAtFile.readStartNode 8 leoAtFile.readStartOthers 1710 leoAtFile.sentinelKind4 228 leoAtFile.skipSentinelStart4 7 leoNodes.copy 1710 leoAtFile.sentinelKind4 3575 g.match 205 g.skip_c_id 1938 g.skip_ws 228 leoAtFile.skipSentinelStart4 228 g.match 456 g.skip_ws 7 leoCommands.all_unique_tnodes_iter 7 leoCommands.rootPosition 7 leoNodes.unique_tnodes_iter 1 leoCommands.all_unique_vnodes_iter 1 leoCommands.rootPosition 1 leoNodes.unique_vnodes_iter 1 leoCommands.nullPosition 1 leoNodes.__init__ 8 leoCommands.rootPosition 8 leoNodes.__nonzero__ 8 leoNodes.copy 250 leoNodes.__init__ 126 g.toUnicode 43 leoNodes.copy 21 leoNodes.getNodeAfterTree 63 leoNodes._linkAsNthChild 63 leoNodes._computeParentsOfChildren 49 leoNodes.anyAtFileNodeName 21 leoNodes.anyAtFileNodeName 28 leoNodes.findAtFileName 281 leoNodes.atAutoNodeName 281 leoNodes.findAtFileName 281 leoNodes.atFileNodeName 281 leoNodes.findAtFileName 278 leoNodes.atRawFileNodeName 278 leoNodes.findAtFileName 285 leoNodes.atThinFileNodeName 285 leoNodes.findAtFileName 165 leoNodes.bodyString 77 g.isUnicode 77 g.toUnicode 77 leoNodes.bodyString 14 leoNodes.clearDirty 7 leoNodes.clearDirty 28 leoNodes.clearVisited 14 leoNodes.clearVisited 7 leoNodes.clearVisitedInTree 7 leoNodes.__iter__ 14 leoNodes.clearVisited 21 leoNodes.next 7 leoNodes.self_and_subtree_iter 80 leoNodes.copy 80 leoNodes.__init__ 1153 leoNodes.findAtFileName 1153 g.match 35 g.match_word 537 g.skip_id 1153 leoNodes.headString 21 leoNodes.getNodeAfterTree 21 leoNodes.copy 21 leoNodes.moveToNodeAfterTree 3264 leoNodes.hasNext 3264 leoNodes._parentVnode 1174 leoNodes.headString 1167 g.isUnicode 1167 g.toUnicode 7 leoNodes.headString 14 leoNodes.isAnyAtFileNode 7 leoNodes.anyAtFileNodeName 7 leoNodes.headString 7 leoNodes.isAnyAtFileNode 562 leoNodes.isAtAutoNode 281 g.choose 281 leoNodes.atAutoNodeName 281 leoNodes.isAtAutoNode 562 leoNodes.isAtFileNode 281 g.choose 281 leoNodes.atFileNodeName 281 leoNodes.isAtFileNode 570 leoNodes.isAtIgnoreNode 285 g.is_special 285 leoNodes.isAtIgnoreNode 556 leoNodes.isAtRawFileNode 278 g.choose 278 leoNodes.atRawFileNodeName 278 leoNodes.isAtRawFileNode 570 leoNodes.isAtThinFileNode 285 g.choose 285 leoNodes.atThinFileNodeName 285 leoNodes.isAtThinFileNode 6 leoNodes.isOrphan 3 leoNodes.isOrphan 2488 leoNodes.moveToNext 2488 leoNodes._parentVnode 28 leoNodes.moveToNodeAfterTree 36 leoNodes.__nonzero__ 36 leoNodes.hasNext 28 leoNodes.moveToNext 8 leoNodes.moveToParent 446 leoNodes.moveToThreadNext 106 leoNodes.__nonzero__ 450 leoNodes.hasNext 101 leoNodes.moveToFirstChild 344 leoNodes.moveToNext 106 leoNodes.moveToParent 2738 leoNodes.moveToThreadNextUnique 11638 leoNodes.<lambda> 9538 leoNodes.__nonzero__ 2778 leoNodes.hasNext 654 leoNodes.moveToFirstChild 2116 leoNodes.moveToNext 662 leoNodes.moveToParent 2987 leoNodes.next 2738 leoNodes.<lambda> 5974 leoNodes.__nonzero__ 189 leoNodes.isEqual 38 leoNodes.moveToParent 168 leoNodes.moveToThreadNext 2738 leoNodes.moveToThreadNextUnique 67 leoNodes.scanGnx 134 g.match 181 g.skip_to_char 14 leoNodes.self_and_parents_iter 14 leoNodes.__init__ 21 leoNodes.self_and_subtree_iter 21 leoNodes.__init__ 64 leoNodes.setBodyString 64 g.toUnicode 7 leoNodes.unique_tnodes_iter 7 leoNodes.__init__ 1 leoNodes.unique_vnodes_iter 1 leoNodes.__init__ 14 leoTkinterFrame.forceLogUpdate 14 Tkinter.update_idletasks 14 leoTkinterFrame.insert 14 Tkinter.insert 14 leoTkinterFrame.toGuiIndex 7 leoTkinterFrame.put 7 Tkinter.update_idletasks 7 leoTkinterFrame.forceLogUpdate 7 leoTkinterFrame.insert 7 leoTkinterFrame.see 7 leoTkinterFrame.selectTab 7 leoTkinterFrame.putnl 7 leoTkinterFrame.forceLogUpdate 7 leoTkinterFrame.insert 7 leoTkinterFrame.see 7 leoTkinterFrame.selectTab 14 leoTkinterFrame.see 14 Tkinter.see 14 leoTkinterFrame.toGuiIndex 14 leoTkinterFrame.selectTab 14 _Pmw.Pmw_1_3.lib.PmwNoteBook.selectpage 1 leoTkinterFrame.setCallback 1 Tkinter.set 28 leoTkinterFrame.toGuiIndex 28 Tkinter.index 14 ntpath.dirname 14 ntpath.split 53 ntpath.isabs 53 ntpath.splitdrive 21 ntpath.join 21 ntpath.isabs 7 ntpath.normpath 7 ntpath.splitdrive 14 ntpath.split 14 ntpath.splitdrive There is a small mystery: the count for readAll itself is zero. It's hard to debug such mysteries because pdb can't be used. But anyway, I think we ignore this small point. Imo, these statistics are a good starting point for designing a rewrite of the atFile read code using mxTextTools. Edward --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "leo-editor" group. To post to this group, send email to leo-editor@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/leo-editor?hl=en -~----------~----~----~----~------~----~------~--~---