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

Re: efficiency



On 04/02/17 08:47 AM, Peter Stephenson wrote:
On Sat, 04 Feb 2017 08:38:52 -0800
Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
Of course.  Still it's good to understand the theory of the thing. As I
said, in practice the difference was a milisecond but I backed the wrong
horse, which is instructive since it suggests that the shell likes fewer
lines more than it likes simplified calculation.
Yes, that does sound right.  In an interpreted language quite a lot of
the overhead is that you need to start from scratch on each line of
input, working out what it is and passing through the hierarchy first of
parsing and then execution.  The math expression is interpreted, too,
and has its own parsing and execution phases, but in a significantly
more limited way.  The actual time taken adding, subtracting and
dividing to do the calculation within that is utterly trivial,
I should think nearer nanoseconds than microseconds.

But the microseconds were for the entire function to execute several times, which is far more than just the math.

pws

Excellent, that's my lesson.



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