The script below reports stats on the current tree (starting from the
level of the currently selected node on down).

For example, for leoPyRef.leo:

   @shadow-test: 25
          @thin: 33
@shadow-test-lax: 2
         @@test: 18
          @test: 486
         @suite: 8
        @@@test: 6
        @@first: 1

(list truncated for brevity)

and then

ALL
       avgbodychrs: 4375
         collapsed: 1514
          bodychrs: 3183454
           visible: 7
          headchrs: 127984
       avgheadchrs: 170
             nodes: 6360
@@button (7)
       avgbodychrs: 1391
         collapsed: 4
          bodychrs: 10595
          headchrs: 450
       avgheadchrs: 86
             nodes: 26
@thin (33)
       avgbodychrs: 7184
         collapsed: 1160
          bodychrs: 2787902
          headchrs: 101789
       avgheadchrs: 185
             nodes: 4986
etc. etc.

I wrote it because I also am finding the qt GUI sluggish, I suspect
part of the issue is hardware

     *-cpu
          product: AMD Athlon(tm) XP 1800+
          size: 1500MHz
          width: 32 bits
          clock: 66MHz
             description: L1 cache
             size: 128KiB
             description: L2 cache
              size: 256KiB
     *-memory
          size: 1009MiB

not the speediest.

Anyway, the script is kind of pointless for evaluating qt because
anyone can test against leoPyRef or similar, but might be useful for
other things, here it is:


from collections import defaultdict
dat = defaultdict(lambda: defaultdict(lambda: 0))

def treestat(dat, p, at, exp):
    hs = p.headString()
    bs = p.bodyString()
    if hs.strip().startswith('@'):
        at = hs.split(None,1)[0]
        dat[None][at] += 1

    for i in dat['ALL'], dat[at]:
        i['headchrs'] += len(hs)
        i['bodychrs'] += len(bs)
        i['nodes'] += 1
        i['avgheadchrs'] += len(hs) / float(i['nodes'])
        i['avgbodychrs'] += len(bs) / float(i['nodes'])
        if exp:
            i['visible'] += 1
        if p.hasChildren():
            if p.isExpanded():
                i['expanded'] += 1
            else:
                i['collapsed'] += 1

    for child in p.children_iter():
        treestat(dat, child, at, exp and p.isExpanded())

for x in p.self_and_siblings_iter():
    treestat(dat, x, 'PLAIN', True)

print
for at in dat[None]:
    print '% 15s: %d' % (at, dat[None][at])
for at in dat:
    if at is None: continue
    if at.startswith('@'):
        print at, '(%d)' % dat[None][at]
    else:
        print at
    for k in dat[at]: 
        print '   % 15s: %d' % (k, dat[at][k])


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to