Hi Vitalije

On Tuesday, July 31, 2018 at 2:50:54 PM UTC+1, vitalije wrote:
>
> Rev 81b1c1422 
> <https://github.com/leo-editor/leo-editor/commit/81b1c142269e25301bc023217900187cd61db341>adds
>  
> support for executing old scripts. It has only 7 added lines.
>
> It also turns off auto-scrolling that I used in the beginning when new Leo 
> tree was without its scrollbars. 
>
> Playing with some scripts and comparing speed of different tree 
> traversals. Here is a script:
>
> import timeit
> def t_one():
>     res = []
>     for p in c.all_positions():
>         res.append('%s%s'%(' '*p.level(), p.h))
>     return '\n'.join(res)
> def t_two():
>     d = c._ltm.data
>     res = []
>     for lev, gnx in zip(d.levels[1:], d.nodes[1:]):
>         nd = d.attrs[gnx]
>         res.append('%s%s'%(' '*lev, nd.h))
>     return '\n'.join(res)
>
> t1 = timeit.timeit(t_one, number=100)*1000/100
> g.es('leo legacy iterator avg: %.2fms'%t1)
>
> c.USE_NEW_MODEL = True
> t1 = timeit.timeit(t_one, number=100)*1000/100
> g.es('Position2 iterator avg: %.2fms'%t1)
> t1 = timeit.timeit(t_two, number=100)*1000/100
> g.es('Pure new model iterator avg: %.2fms'%t1)
>
>
> and here are the results on my machine with unitTests.leo outline:
> leo legacy iterator avg: 23.76ms
> Position2 iterator avg: 18.75ms
> Pure new model iterator avg: 2.37ms
>
> As you can see using traditional c.all_positions with USE_NEW_MODEL=True 
> is slightly faster then the original one. It uses class Position2 which has 
> the same interface as Position class, but uses data from the new model. But 
> it is possible to compute the same result even faster by using new 
> traversal options. In the above example this approach computes the same 
> result 10 times faster.
>
> Conclusion: the old scripts will work (most of them) as they did before or 
> slightly faster, but with a little bit adjustment they can run even faster. 
> I believe that many user will find worthwhile the effort to change their 
> scripts to be able to use these speed improvements. I would also suggest a 
> setting that will allow users to drop the support of the backward 
> compatibility in exchange for speed.
>
> Vitalije
>

A small point; I suggest not calling the current code 'leo legacy...'. 
There is a presumption there that is unwarranted, I think.

That aside, although I am only tangentially following you work, I find it, 
and your descriptions, very interesting.

    Regards
    Jon N

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to