Date: Fri, 04 Apr 1997 17:52:15 +0800 From: Peter Wemm <peter@spinner.DIALix.COM> To: Eugeny Kuzakov <kev@l321.omsk.net.ru> Cc: "Alexander V. Lukyanov" <lav@video.yars.free.net>, bugs@freebsd.org, ache@freebsd.org Subject: Re: sscanf is slow on 2.2.1 Message-ID: <199704040952.RAA01247@spinner.DIALix.COM> In-Reply-To: Your message of "Fri, 04 Apr 1997 16:16:11 %2B0700." <Pine.BSD.3.95.970404161401.26348B-100000@l321.omsk.net.ru>
index | next in thread | previous in thread | raw e-mail
Eugeny Kuzakov wrote:
> On Thu, 3 Apr 1997, Alexander V. Lukyanov wrote:
>
> > The program below works awfully slowly on FreeBSD 2.2.1, and quite normally
> > on Solaris 2.5, Linux, Digital Unix etc.
> >
> > Linux on i586 100Mhz:
> > real 0m26.020s
> > user 0m24.240s
> > sys 0m0.400s
> >
> > FreeBSD 2.1.5 on i586 66Mhz:
> > 104.06 real 51.97 user 0.00 sys
> My machine:
> P100/32MB/FreeBSD 2.1/Proxy SQUID/router to ISP (33600Kb)/30
> logined users:
>
> 30.65 real 29.33 user 0.02 sys
> 8-()
>
> >
> > FreeBSD 2.2.1 on i586 133Mhz:
> > 737.01 real 588.48 user 0.43 sys
> >
> > More than 10 times slower than 2.1.5 on a weaker system.
> > Obviously, that time is spent inside libc.
Hmm, most likely it's in the locale stuff.. :-( Here's a suspicious set
of diffs from -current realtive to 2.1:
@@ -712,15 +729,19 @@
* we just stored in the table (c).
*/
n = *fmt;
- if (n == ']' || n < c) {
+ if (n == ']' || __collate_range_cmp (n, c) < 0) {
c = '-';
break; /* resume the for(;;) */
}
fmt++;
- do { /* fill in the range */
- tab[++c] = v;
- } while (c < n);
+ /* fill in the range */
+ for (i = 0; i < 256; i ++)
+ if ( __collate_range_cmp (c, i) < 0
+ && __collate_range_cmp (i, n) <= 0
+ )
+ tab[i] = v;
#if 1 /* XXX another disgusting compatibility hack */
+ c = n;
/*
* Alas, the V7 Unix scanf also treats formats
The commit log message was:
----------------------------
revision 1.5
date: 1997/01/16 07:36:14; author: ache; state: Exp; lines: +13 -8
Use collate for national [a-z]-like ranges
Should go in 2.2
----------------------------
Ouch..
-Peter
> > ---
> > #include <stdio.h>
> > int main()
> > {
> > int i;
> > char str[256];
> > for(i=0; i<1000000; i++)
> > sscanf("abcde","%255[a-zA-Z]",str);
> > return 0;
> > }
> > ---
> > Alexander.
> >
>
> Best wishes, Eugeny Kuzakov
> Laboratory 321 ( Omsk, Russia )
> kev@l321.omsk.net.ru
Cheers,
-Peter
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199704040952.RAA01247>
