Re: Changing data types, Continued

new topic     » goto parent     » topic index » view thread      » older message » newer message

euman, you sent this to the wrong address i beleive

----- Original Message -----
From: "H.W Overman" <euman at bellsouth.net>
To: <gertie at visionsix.com>
Cc: "Euphoria Mailing List" <EUforum at topica.com>
Subject: Re: Changing data types, Continued


>
>
> Kat,
>
> This was a preliminary version I wrote for Allen back at the beginning
> of his project, I have several versions I sent him but this one is what
> you would probably be interested in...
>
> Two parts (.exw programs) are here, one to create and write the file, the
> other to read the file...
>
> I hope I hadnt changed anything to screw this up over time, Im in Linux
right
> now so I cant test it but it should still be ok...
> Note: possible to tweak further!
>
> -- Code part 1
>
> -- PART 1 speedread_write.exw creates the 8mg file
>
> -- SpeedRead_write Binary file in Windows
> -- Euman 2004
> -- Based on Allen V. Robnett's idea for nodes rambase
>
> without type_check
> without trace
> without warning
>
> include get.e
>
> integer fn, fp, x
>
> constant max_node_level = 20
>
> fn = -1
> while fn=-1 do
>   fn = open("nodes.dat", "rb")
>   if fn=-1 then
>      puts(1,"No Nodes file. Create it (Y/N)? \n")
>      x = wait_key()
>      if x='y' or x='Y' then
>         fn = open("nodes.dat", "wb")
>         puts(1,"Creating node table...Please wait\n")
>         for i=1 to power(2, max_node_level) do
>             for j = 1 to 8 do
>                 puts(fn, '_')
>             end for
>         end for
>         puts(1,"Done...\n")
>         close(fn)
>      end if
>   else
>   close(fn)
>   end if
>   exit
> end while
>
> -- PART 2 speedread.exw reads written file from output of above code
>
> -- SpeedRead Binary file in Windows
> -- LOOK FOR: pass name of file (below) and .dat file containing 8mg
> -- Euman 2004
> -- W/ minor tweak by Tommy Carlier noted below
>
> without type_check
> with trace
>
> include machine.e
> include file.e
> include dll.e
>
> atom t1, t2, fn, lFileLen, result
> sequence lFile, line
> integer char
>
> atom kernel32
> kernel32 = open_dll("kernel32.dll")
>
> constant
> xCreateFile = define_c_func(kernel32,"CreateFileA",
> {C_POINTER,C_LONG,C_LONG,C_POINTER
> ,C_LONG,C_LONG,C_INT},C_LONG),
> xReadFile = define_c_func(kernel32,"ReadFile",
> {C_INT,C_POINTER,C_UINT,C_POINTER,
> C_POINTER},C_LONG)
>
> global constant
>   GENERIC_READ             = #80000000,
>   FILE_ATTRIBUTE_NORMAL    = #80,
>   FILE_FLAG_SEQUENTIAL_SCAN= #8000000,
>   OPEN_EXISTING            = 3
>
> atom hFile
>
> global function CreateFile(sequence fname)
> atom FileName
>      FileName = allocate_string(fname)
>      hFile = c_func(xCreateFile,{FileName,
>                                 GENERIC_READ,
>                                 0,
>                                 NULL,
>                                 OPEN_EXISTING,
>
FILE_ATTRIBUTE_NORMAL+FILE_FLAG_SEQUENTIAL_SCAN,
>                                 NULL})
>     return hFile
> end function
>
> atom lpNumberOfBytesRead
> lpNumberOfBytesRead = allocate(4) --lpNumberOfBytesRead
>
> function ReadFile(atom hFile, atom lpBuffer, atom nNumberOfBytesToRead)
>   return c_func(xReadFile,
> {hFile,lpBuffer,nNumberOfBytesToRead,lpNumberOfBytesRead,
> 0})
> end function
>
> sequence yourfile
> yourfile = "nodes.dat" -- pass name of file
>
> fn = open(yourfile, "r")
> lFileLen = seek(fn, -1)
> lFileLen = where(fn)
> close(fn)
>
> atom lpFileBuff, cIN, cIndex, cMaxIndex
> lpFileBuff = allocate(lFileLen)
> cIN = 0
>
> t1 = time()
> hFile = CreateFile(yourfile)
> result = ReadFile(hFile, lpFileBuff, lFileLen)
>
> -- we havent checked lpNumberOfBytesRead perhaps you may want to
> -- compare this to lFileLen before you start the loop, in this case
> -- the file is pretty small. '8,000,000 chars'
>
> -- Plus, this assumes binary read and no crlf chars exist
> trace(1)
> line = repeat(0, lFileLen / 8)
> atom lIndex
>
> if result then
>
>    cMaxIndex = lpFileBuff + lFileLen
>    cIndex = lpFileBuff
>    lIndex = 1
>
>   -- tweak by Tommy Carlier
>    while cIndex < cMaxIndex do
>       line[lIndex] = peek({cIndex, 8})
>       cIndex += 8
>       lIndex += 1
>    end while
>
> end if
> free(lpFileBuff)
>
> -- take trace out to get correct speed!
> t2 = time()- t1
> printf(1,"Average Time : %1.4f sec\n", t2 )
>
> if getc(0) then end if
>
> -- END CODES
>
> Euman
>
> On Monday 22 March 2004 11:17 am, Kat wrote:
> > On 22 Mar 2004, at 10:35, H.W Overman wrote:
> > >
> > > > I am very interested in seeing code for how you are loading and
> > > > accessing 200meg file in ram now.
> > > >
> > > > Kat,
> > >
> > > Sure Kat, I wrote it! Allen shouldve mentioned that...
> >
> > I did a search in the RDS archives for Euman and Overman, and nothing
> > showed on the memory stash code. I remember you were doing something
> > about this, or someone was, last year, i think.
> >
> > Kat,
> > looking interested,
> > powered by caffine and cheetoes.
>
> --
> message authentication: /409&*777/-682/+905
>
>
>
> For Topica's complete suite of email marketing solutions visit:
> http://www.topica.com/?p=TEXFOOTER
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu