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: Michael & Amy Hartsough Subject: Re: CRC in Ada? Date: 1997/03/16 Message-ID: <332C9185.61C1@worldnet.att.net>#1/1 X-Deja-AN: 226047678 References: <1997Mar2.220652@nova.wright.edu> <331bf6ce.2832564@news.logica.co.uk> <332B5EBD.3D9E@worldnet.att.net> Organization: AT&T WorldNet Services Newsgroups: comp.lang.ada Date: 1997-03-16T00:00:00+00:00 List-Id: Robert Dewar wrote: > > < k > the C++ CRC32 27 seconds to checksum the same file! Timings were performed using > the stopwatch function on my Timex. ;^) Why the difference? File I/O. Turns out > all but about 8-9 seconds of those 18 minutes were spent reading from the hard d > isk!>> > > It would be interesting to see how you coded this up, surely you did not > use Text_IO for the I/O (as I say, I have almost never seen people use I instantiated Sequential I/O with an unsigned 8-bit type. > One other thing here is that I generally find that when people recode a > piece of code written in language X into language Y, they often do a much > worse job than if they wrote a new program from scratch in Y. It is much > too easy to copy inappropriate approaches and design from the other > implementation. It would be an interesting experiment to code up something > like the CRC efficiently in Ada, which of course can be done, and then > have it translated to C++. For example, if one used packed arrays in Ada, > you can often get some very efficient code that does not map nicely into > C++ at all. The proper approach for recoding this in C++ is to redesign > the data structures, but it would be a path of lesser resistance to emulate > the packed stuff inefficiently in C. In this particular case I don't think you'd see a great deal of difference. There's some anding and xoring, a table look up and the 8-bit shift right and that's about it (the code's at work, I'm at home now). So you're basically about as close to machine code as you can get with a HOL. If you don't include the file access time, the Ada and C++ execution times were nearly identical. Later, Michael