Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!lll-lcc!pyramid!prls!mips!mash From: mash@mips.UUCP Newsgroups: comp.arch,comp.lang.c Subject: Re: String Processing Instruction Message-ID: <238@winchester.mips.UUCP> Date: Sat, 28-Mar-87 17:31:58 EST Article-I.D.: winchest.238 Posted: Sat Mar 28 17:31:58 1987 Date-Received: Sun, 29-Mar-87 09:57:52 EST References: <15292@amdcad.UUCP> <978@ames.UUCP> <15304@amdcad.UUCP> <232@winchester.mips.UUCP> <15317@amdcad.UUCP> Reply-To: mash@winchester.UUCP (John Mashey) Distribution: na Organization: MIPS Computer Systems, Sunnyvale, CA Lines: 59 Keywords: strlen strcmp strcpy Xref: utgpu comp.arch:693 comp.lang.c:1366 In article <15317@amdcad.UUCP> rpw3@amdcad.UUCP (Rob Warnock) writes: >Well, John Mashey's numbers were certainly counter-intuitive to ME, given >that those programs bang away at characters all the time, but we should >look at one more thing: > >When were nroff/grep/yacc written compared to when str* was standardized >in the library? After all, the str* libraries didn't spring full-blown on >day one with those exact sematics and calling sequences (I'm guessing). >I'll also guess (could easily be wrong) that there is a lot more string >stuff going on than you see in the str* statistics, and that it's hand >coded "in line" (in C, of course). Yes, those were old programs. I'd be happy to hear of suggestions for specific programs to check. It's absolutely sure that there was plenty of string stuff going on, coded in C. [Of coruse, some of the string stuff is algorithmic work that hardware isn't likely to support for a while, i.e., regular-expression matching.] > >Finally, don't forget str{,r}chr (a.k.a. {,r}index). Things like "ls -l" >beat on those really hard (at least in System-V), since way down at the >bottom a lot of time is spent (I'm guessing) tearing apart /etc/passwd >entries (go look at "getpwent" & friends). I generally looked for str* routines; the others were generally in the noise. Following are the stats for SYS V : ls -l /usr Profile listing generated Sat Mar 28 14:19:29 1987 with: ---------------------------------------------------------------------------- * -p[rocedures] using basic-block counts; * * sorted in descending order by the number of cycles executed in each * * procedure; unexecuted procedures are excluded * ---------------------------------------------------------------------------- 1139801 cycles cycles %cycles cum % cycles bytes procedure (file) /call /line 511480 44.87 44.87 6558 22 getname (ls.c) 310413 27.23 72.11 16 40 fgetc (../fgetc.c) 99006 8.69 80.79 43 28 _flsbuf (../flsbuf.c) 79820 7.00 87.80 340 17 _doprnt (../doprnt.c) 18830 1.65 89.45 54 23 select (ls.c) 15073 1.32 90.77 321 19 gmtime (../ctime.c) .... 1655 0.15 98.79 10 5 strcmp (../strcmp.s) .... 1338 0.12 99.18 18 5 strlen (../strlen.s) .... 63 0.01 99.96 8 10 strchr (../strchr.c) [Surprise! str* stuff isn't on the map in this one. Just goes to show that even experienced [and Rob is] folks' intuition needs checking. >Well, this surprised me also.] This whole string-processing discussion has been quite worthwhile, if only to remind us that we often discuss pretty esoteric things in this newsgroup, while at the same time, we sometimes don't have the foggiest ideas on even basic program behavior!! -- -john mashey DISCLAIMER: UUCP: {decvax,ucbvax,ihnp4}!decwrl!mips!mash, DDD: 408-720-1700, x253 USPS: MIPS Computer Systems, 930 E. Arques, Sunnyvale, CA 94086