Nicolas Bonifas wrote:
>> > I don't know much about bash internals, but there is probably room for
>> > a huge performance improvement in speeding up the eval builtin.
>> > What do you think about it? Would it be a difficult task?
>>
>> It is more likely to be the command substitution that is slow.
>
> You're right:
> $ time (echo `dircolors` > /dev/null)
>
> real 0m0.318s
> user 0m0.312s
> sys 0m0.008s
>
> I ran the previous tests with bash-3.1. With bash-3.2, echo
> `dircolors` take 0.088s of user time (1/4th of the time needed by
> bash-3.1), and dircolors > dircolors_output && sh ./dircolors_output
> still takes 0.004s, so it is more than 20 times faster than using
> command substitution.
>
> So, do you think that speeding up command substitution would be a
> difficult task?
I assume you know that the speed issues most likely come from the
operating system's supporting functions like the fork() and exec*()
family members? Executing another process takes time and there is not
much you can do about it.
If you have speed problems while using a huge amount of command
substitutions you either have a bad script design or use the wrong
language for your specific task IMHO.
J.