From owner-freebsd-bugs Fri Apr 4 02:09:32 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id CAA00298 for bugs-outgoing; Fri, 4 Apr 1997 02:09:32 -0800 (PST) Received: from spinner.DIALix.COM (root@spinner.dialix.com [192.203.228.67]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id CAA00261; Fri, 4 Apr 1997 02:08:14 -0800 (PST) Received: from spinner.DIALix.COM (peter@localhost.DIALix.oz.au [127.0.0.1]) by spinner.DIALix.COM (8.8.5/8.8.5) with ESMTP id RAA01247; Fri, 4 Apr 1997 17:52:16 +0800 (WST) Message-Id: <199704040952.RAA01247@spinner.DIALix.COM> X-Mailer: exmh version 2.0gamma 1/27/96 To: Eugeny Kuzakov cc: "Alexander V. Lukyanov" , bugs@freebsd.org, ache@freebsd.org Subject: Re: sscanf is slow on 2.2.1 In-reply-to: Your message of "Fri, 04 Apr 1997 16:16:11 +0700." Date: Fri, 04 Apr 1997 17:52:15 +0800 From: Peter Wemm Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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 > > 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