On Thursday, June 7, 2018 at 10:11:25 AM UTC-5, Edward K. Ream wrote:
>
> #927 <https://github.com/leo-editor/leo-editor/issues/924> performance
> questions has revealed some spectacular performance gains. The new code is
> in the "perf" branch.
>
The trick of showing the callers to functions reveals a lot. See #927 for
the code that gathers the statistics.
I also changed g.printStats to print the statistics in frequency order.
g.match_word is the only other function in leoGlobals.py that is called
surprisingly often:
# Yikes: createAllButtons takes a long time.
244179 g.match_word:createAllButtons,isAtIgnoreNode,isAtIgnoreNode,
is_special
76017 g.match_word:doHandlersForTag,callTagHandler,onCreate,
createAllButtons
16801 g.match_word:onCreate,createAllButtons,isAtIgnoreNode,isAtIgnoreNode
# Nothing else matters much...
7540 g.match_word:writeFromString,writeOpenFile,putBody,directiveKind4
2861 g.match_word:readAll,isAtIgnoreNode,isAtIgnoreNode,is_special
2572 g.match_word:putVnode,isAtIgnoreNode,isAtIgnoreNode,
is_special
1824 g.match_word:fullPath,anyAtFileNodeName,anyAtFileNodeName,
findAtFileName
1646 g.match_word:putLine,putAtOthersLine,putBody,directiveKind4
1089 g.match_word:isAnyAtFileNode,isAnyAtFileNode,anyAtFileNodeName,
findAtFileName
The culprit is g.is_special:
def is_special(s, i, directive):
'''Return True if the body text contains the @ directive.'''
assert(directive and directive[0] == '@')
# All directives except @others must start the line.
skip_flag = directive in ("@others", "@all")
while i < len(s):
if g.match_word(s, i, directive):
return True, i
else:
i = g.skip_line(s, i)
if skip_flag:
i = g.skip_ws(s, i)
return False, -1
Clearly, this should be rewritten to use regular expressions. This will
eliminate most calls to g.match_word and will speed up Leo considerably.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.