[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making the present code run faster



On Mon, 29 Jan 2001 13:34:04 -0600, Tom Droege 
<tdroege@veriomail.com> or somebody wrote:

>   Then it is not a question of CPU speed, but rather disk
>speed or some interaction between the BASIC code and disk
>writing.

The biggest single factor in speeding up my Pascal
code was to quit trying to write in 2880 Byte chunks
(for FITS) and instead to block the data up in 2^n
segments. The odd sizes really screwed up the system
with or without SMARTDRV. With SMARTDRV, one could
use relatively short 2^n blocks without penalty. I used
16384 Bytes.

I know nothing about Windows caching - I suspect it
will also be badly affected by non-2^n blocks.

My Pascal code looked like this:
  L := NAxis1*NAxis2 ; { Size in 16-bit words }
  N := LBufW ; { 8192 = 16384/2 }
  I := 0 ;
  Repeat
    B1 := InPortB(PortNo) ;
    B2 := InPortB(PortNo) ;
    BufA[I] := 256*Word(B1) + B2 ;
    B1 := InPortB(PortNo) ;
    B2 := InPortB(PortNo) ;
    BufB[I] := 256*Word(B1) + B2 ;
    Inc(I) ;
    If (I >= N) Then Begin
      BlockWrite(FileA, BufA, N) ;
      BlockWrite(FileB, BufB, N) ;
      Dec(L, N) ;
      N := L ; If (N > LBufW) Then N := LBufW ;
      I := 0 ;
    End ;
  Until (L <= 0) ;

I'm sorry, but I don't know enough BASIC to translate
this back. Note that the last disk writes are a
different size from the others so I could not
use File Of BufType; I was effectively using
File Of Word; N is the number of words to be
written (record size of 2 Bytes).

Andrew Bennett, Avondale Vineyard