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=0.7 required=5.0 tests=BAYES_00,MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,95c23095599677a5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-01-22 07:30:18 PST Path: supernews.google.com!sn-xit-02!supernews.com!bignews.mediaways.net!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: Ted Dennison Newsgroups: comp.lang.ada Subject: Re: Optimization Question Date: Mon, 22 Jan 2001 15:24:53 GMT Organization: Deja.com Message-ID: <94hjbp$ks6$1@nnrp1.deja.com> References: <94ftfu$b59$1@nnrp1.deja.com> <94g431$ge3$1@nnrp1.deja.com> NNTP-Posting-Host: 204.48.27.130 X-Article-Creation-Date: Mon Jan 22 15:24:53 2001 GMT X-Http-User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; 0.7) Gecko/20010109 X-Http-Proxy: 1.0 x56.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 X-MyDeja-Info: XMYDJUIDtedennison Xref: supernews.google.com comp.lang.ada:4303 Date: 2001-01-22T15:24:53+00:00 List-Id: In article <94g431$ge3$1@nnrp1.deja.com>, Robert Dewar wrote: > In article <94ftfu$b59$1@nnrp1.deja.com>, > dvdeug@my-deja.com wrote: > > <> > > I am *amazed* that this is only ten times slower when the > I/O is done in such a perfectly gruesome manner (sequential > I/O instantiated on bytes). > > It is elementary that you want to read big chunks of a file > at a time. What GNAT does is to read the entire source of As a point of reference, I'm in the process of writing a little app in Windows NT to split files for the purpose of distributing large files on floppies. My first iteration took the dumb approach and used Direct_IO instantiated on bytes, copying each byte from one disk to the other. Filling a whole floppy in this manner took me about 4.5 minutes. However, I noticed that copying the same file to the floppy using Windows explorer takes about 45 seconds. For my next trick, I changed to using Ada.Streams.Stream_IO. First I tried to copy the whole disks' worth of data into a buffer using 'Read, then copy it to the floppy using 'Write. It still took 4.5 minutes. That's not suprising, since 'Read on an array is defined as individual 'Reads for each element. So next I changed the code to instead call Ada.Streams.Read and Ada.Streams.Write directly for the entire amount of data that is going on the disk (one operation each per disk). When I compiled and ran this, a disk's worht of data copied in....(drumroll please)...45 seconds, just like for Windows. Of course 45 seconds is a bit long to wait with no feedback, so I changed it to only write portions of the disk's worth of data, and output a '*' character to the screen between them. Unsuprisingly, the amount of chunks used has a serious impact on the amount of time the operation takes. So one has to strike a balance. I found a realtively happy medium at 10 copies per floppy. That only increases the copy time by about 10 seconds. Anyway, if you want to try to perform large file operations, it looks like Stream_IO and Ada.Streams.Read and Write are the way to go. The only other way I could think to do it would be to dynamicly instantiate Sequential or Direct IO with the data size you want to use for each I/O operation. That would be a pain. -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/