Re: [RFC/PATCH 1/5] gettext: fix bug in git-sh-i18n's eval_gettext() by using envsubst(1)
- From
Johannes Sixt <j.sixt@viscovery.net>
- Date
- Nov 9, 2010, 11:42 UTC
- Message-ID
- <4CD933BF.6070105@viscovery.net>
- In-Reply-To
- <AANLkTins_qq=unv101JuV_CVvkp3KbTq5qycva7bZ7sm@mail.gmail.com>
Am 11/9/2010 11:52, schrieb Ævar Arnfjörð Bjarmason:
> On Tue, Nov 9, 2010 at 11:36, Johannes Sixt <j.sixt@viscovery.net> wrote:
>> $ time (for i in {1..100}; do git version; done) > /dev/null
>>
>> real 0m5.610s...
>> $ time (for i in {1..100}; do eval_gettext foobar; done) > /dev/null
>>
>> real 0m20.578s...
Show 9 quoted lines
>> Note that there are only 100 iterations, so we are talking about 0.2 >> seconds per eval_gettext call! That's an awful lot of time even for a >> single error message. > > Thanks for elaborating. But just so I understand you correctly it's a > cost of invoking *any* program in shellscripts on Windows? So e.g. 10 > sed calls would cost the same as 10 git-sh-i18n--envsubst calls (but > of course 5 eval_gettext() calls, since it calls git-sh-i18n--envsubst > twice).
An invocation of sed, cat, etc. (POSIX/MSYS tools) is cheaper by a factor of 2 than a git invocation for a reason that I do not understand. (Perhaps it has to do with the number of DLLs that are linked; git has 9 static dependencies, MSYS tools only 3.)
eval_gettext involves 2 git invocation (git-sh-i18n--envsubst counts as much as git) and 1 subshell in practice (some subshells are optimized away).
> So e.g. using eval_gettext once isn't a bigger problem than calling > some trivial sed substitution twice?
Look at the timings: In my book, eval_gettext counts like about 8 sed substitutions.
-- Hannes