From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9c86eb13dd395066 X-Google-Attributes: gid103376,public From: ohk@edeber.tfdt-o.nta.no (Ole-Hjalmar Kristensen FOU.TD/DELAB) Subject: Re: CRC in Ada? Date: 1997/03/10 Message-ID: #1/1 X-Deja-AN: 224383486 References: <1997Mar2.220652@nova.wright.edu> Organization: Telenor Online Public Access Newsgroups: comp.lang.ada Date: 1997-03-10T00:00:00+00:00 List-Id: In article dewar@merv.cs.nyu.edu (Robert Dewar) writes: Fergus said <> Well it does not surprise me, and I don't really understand why it surprises you. I would expect a large difference here, and indeed it is what we see! Just shows that measurements can be a useful substitute for guesswork, though measurements have the weakness of being system specific, so nothing really substitutes for a lot of experience on a lot of difrerent machiens! He didn't say it, I did. So tell me, why would you expect a large difference? I would expect the optimizer to recognize that both (&_iob[0])->_cnt and (&_iob[0])->_ptr are constant expressions, so that the two loops differ mainly in using indirect or direct addressing. Bu I suppose Im'm expecting too much from optimizers. Here is a version of the first program after it has passed through cpp: main() { setvbuf((&_iob[0]),0,0000,4096); int c,total=0; while ((c = (--((&_iob[0]))->_cnt < 0 ? __filbuf((&_iob[0])) : (int)*((&_iob[0]))->_ptr++)) != (-1)) total++; printf("total %d\n",total); } And the second: main() { int c,n,total=0; while ((n = read(0,buf,sizeof(buf))) > 0) { int i; for (i = 0; i < n; i++) { c = buf[i]; total++; } } printf("total %d\n",total); } Ole-Hj. Kristensen