1. Re: Digest for EUforum at topica.com, issue 3230
- Posted by "Kat" <gertie at visionsix.com> Dec 17, 2003
- 453 views
On 17 Dec 2003, at 10:02, Christian Cuvier wrote: > > > > Date: Mon, 15 Dec 2003 17:32:37 -0600 > > From: "Kat" <gertie at visionsix.com> > > Subject: Re: getc( ) and gets( ) speed > > > > > > On 16 Dec 2003, at 8:44, Derek Parnell wrote: > > > >> > >> ----- Original Message ----- > >> From: "Euman" <euman at bellsouth.net> > >> To: <EUforum at topica.com> > >> Sent: Tuesday, December 16, 2003 3:01 AM > >> Subject: Re: getc( ) and gets( ) speed > >> > >> > >> [snip] > >> > > >> > what about 13,10 (crlf) from each line ending > >> > if I have 5000 lines with 201 bytes and I need > >> > only 200, I would need to bypass the crlf on each > >> > line.. > >> > > >> > This shoot holes in the theory that using getc( ) > >> > is faster than gets( ) for most things. > >> > > >> > >> Never heard of that theory. > >> > >> But think about it, you need to call getc() for each and every character > >> inside some form of (slow) Euphoria loop; but gets() only needs to be > >> called > >> for each line (multiple characters per time), so in many circumstances > >> gets() > >> will be faster then getc(). However, gets() only works for text files, it > >> makes a mess of binary files. > > > > Can > > FileContents = fgetb(filehandle,1,SizeOfFile) > > get the entire file without using getc() behind the scene? > > > > Kat > > iirc, some languages do it the other way round: there's actually a block file > read on the first getc() (or whatever you call ReadNextByte(handle)). That > block > is cached and the subsequent getc() calls read from the RAM cache block for > obvious performance gains. In a nutshell, getc() uses fgetb() behind the scene > actually. > Don't know whether Eu source does this, but it's a quite widespread scheme > afaik. Afaik, Eu relies on the OS to cache the blocks read from the disk, meaning getc must make an OS call for each getc. But it am thinking Bach does fgetb() like olde pascal trick of allocating a memory section you spec, and then telling the OS or bios to fill it, and then pointing a variable to it? Btw, another speedy thing speed freaks can do is use a ramdrive just for this purpose. Tell the OS to copy the file to the ramdrive before you need it, and use it as allocated memory, accessed by file commands. Very useful if you do a lot of random changes to a large file. Kat