// ScanTimer.bcpl
// Copyright Xerox Corporation 1979
// Last modified August 28, 1979  9:18 PM by Taft

// Bldr ScanTimer GP

get "Streams.d"
get "AltoFileSys.d"

external
[
// incoming procedures
SetupReadParam; ReadParam
InitScanStream; GetScanStreamBuffer; FinishScanStream
Ws; Wns; Gets; Closes; Timer

// incoming statics
dsp; keys
]

//----------------------------------------------------------------------------
let TestScan() be
//----------------------------------------------------------------------------[
SetupReadParam()
let nBufs = ReadParam($D, "Number of buffers: ")
if nBufs ls 1 then nBufs = 0
if nBufs gr 25 then nBufs = 25
let buffers = vec 25*256
let bufVec = vec 25
for i = 0 to nBufs-1 do bufVec!i = buffers + 256*i

   [
   let name = vec 127
   let stream = ReadParam($I, "Input file: ", name, 0, true)
   if stream eq -1 break
   Ws("*n"); Ws(name)
   let ssd = InitScanStream(stream, bufVec, nBufs)

   let startTime, endTime = vec 1, vec 1
   Timer(startTime)

   let pages = 0
   until GetScanStreamBuffer(ssd) eq 0 do pages = pages+1

   FinishScanStream(ssd)
   Timer(endTime)
   Closes(stream)
   Ws("   ")
   Wns(dsp, pages)
   Ws(" pages, ")
   Wns(dsp, endTime!1-startTime!1)
   Ws(" ms")
   ] repeat
]