Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

the source of slow large for loops



I don't know if anyone looked into why things like
for i in {1..700000}; do true; done
is extremely slow in zsh, so I did now. Turns out zhalloc is extremely
slow, and for the above loop, one particular line runs 12049901132
times according to gcov. (It takes around 10 minutes). If I add early
returns of malloc() and realloc() to zhalloc and hrealloc, the loop
runs in 3 seconds (but leaks a couple of hundred megabytes memory).

This is mostly a FYI thing, not really intending to do anything about
it or expecting anything, but I've always wondered where the slowness
was and now I know. :)

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author