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: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: CRC in Ada? Date: 1997/03/12 Message-ID: #1/1 X-Deja-AN: 224924230 References: <1997Mar2.220652@nova.wright.edu> <1997Mar5.131846.1@eisner> <5fmo1k$adm@mulga.cs.mu.OZ.AU> <1997Mar6.114441.1@eisner> <1997Mar7.090814.1@eisner> <33206340.2616@bix.com> <5g157e$pqf@ratatosk.uio.no> <5g1qtg$4ad$1@A-abe.resnet.ucsb.edu> <5g4k31$g54$1@A-abe.resnet.ucsb.edu> Organization: New York University Newsgroups: comp.lang.ada Date: 1997-03-12T00:00:00+00:00 List-Id: Graham says <<>Sure you can read character by character, but you are paying a considerable >price, even in C, for doing so! Actually: virtually none.>> Well words like considerable and virtually are not very quantitative. There definitely is a price in going character by character (even Balter thinks this extra price might be dominant in something like "cat"). Every system where I have measured the effect (e.g. the difference in a compiler that reads large blocks, or does character by character reads, I have seen enough difference to be worth the effort of doing IO in blocks. This is especially true if you can put a sentinel at the end of the block that will naturally be detected by your processing, e.g. an end-of-file mark of some kind in the compiler case, so that you can then process character by character with out a test for buffer exhaustion (once you commit to using getchar, you do of course have a test on each character read for buffer exhuastion, because at that level it is not under your control). GNAT actually works exactly this way, it reads the entire source with a single read, and then puts an end of file sentinel at the end of the source. This provides noticable speed up over character by character processing.