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

Re: efficiency



On Sat, 04 Feb 2017 07:39:28 -0800
Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> I think what I was really asking is if, in an interpreted language the 
> time spent calculating is offset by the time spent parsing.  That is, in 
> C you'd be more efficient doing the calculation once (besides what you 
> say above), but maybe in zsh the important thing is to reduce the number 
> of lines or the number of variables or something like that.  Or, on the 
> contrary, maybe the simpler form is doubly better since the lines are 
> shorter and thus save parsing time as well as calculation time.

Typically, in a real script, you'd find the difference in time made so
little difference having it look neat was preferable.  You'd only start
looking at optimisations if this was in an inner loop and had to run
many times; or was in a function that lots of users had to run very many
times a day; or involved a significantly larger amount of data if done
one way rather than the other; or something like that.

I'm sure this has come up before, but if you're in a position where a
saving of this kind is important, there's a good chance you shouldn't
really be using a shell at all.

pws



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