> From: Daiki Ueno <u...@gnu.org>
> Cc: Eli Zaretskii <e...@gnu.org>, bug-gnulib@gnu.org
> Date: Tue, 27 Jan 2015 15:14:36 +0900
> 
> I took a bit more serious attempt to this, and ended up with the
> attached patch.  Using the following test program:
> 
>   #include "config.h"
>   #include "localcharset.h"
>   #include <stdio.h>
> 
>   int main (void)
>   {
>     int i;
> 
>     printf ("%s\n", locale_charset ());
>     for (i = 0; i < 1000000; i++)
>       locale_charset ();
>     printf ("%s\n", locale_charset ());
> 
>     return 0;
>   }
> 
> it resulted in a significant performance improvement, although my test
> environment is on Wine (I guess Eli could do testing under a more
> practical setting).
> 
> Before:
> 
>   CP1252
>   CP1252
> 
>   real    0m3.048s
>   user    0m0.100s
>   sys     0m0.070s
> 
> After:
> 
>   CP1252
>   CP1252
> 
>   real    0m0.314s
>   user    0m0.120s
>   sys     0m0.050s

Thanks.  This improves things, but unfortunately not enough.  The
reason is that call to setlocale at the beginning of locale_charset,
which is always made.  If I replace that call with a constant string,
I get a 20-fold speedup, and the display of large nodes in the Info
reader becomes instantaneous, as it was in v5.2.

Here are my timings, measured on Windows XPSP3, after enlarging the
loop count to 2000000, to get the fastest version out of the
quantization error of the system clock:

Original version:

  real    00h00m04.748s
  user    00h00m04.750s
  sys     00h00m00.000s

With values cached in thread-local storage:

  real    00h00m01.280s
  user    00h00m01.281s
  sys     00h00m00.015s

Without the call to setlocale in locale_charset:

  real    00h00m00.062s
  user    00h00m00.046s
  sys     00h00m00.031s

Reply via email to