-- File [Ivy]<Nelson>Lupine>LupineExerciserPrivate.mesa.
-- Last edited by BZM on 14-Mar-82 13:23:46.

-- LupineExerciser*Impl cooperate to export LupineExerciserPrivate.


DIRECTORY
  LupineExerciser USING [
    Counter, Handle,
    StandardPasses, StandardTrialsPerPass, StandardTestsPerTrial ],
  TTY USING [Handle];


LupineExerciserPrivate: DEFINITIONS
  = BEGIN OPEN LupineExerciser;


-- Runtime parameters.

  TestParameters: TYPE = MACHINE DEPENDENT RECORD [
    useDoradoClock (0): BOOLEAN ← FALSE,
    countOnlyEmulatorCycles (1): BOOLEAN ← FALSE,
    checkResults (2:0..0): BOOLEAN ← TRUE,
    testRandomly (2:1..15): BOOLEAN ← FALSE,
    passes (3): Counter ← StandardPasses,
    trialsPerPass (4), maxTrialsPerPass (5): Counter ← StandardTrialsPerPass,
    testsPerTrial (6), maxTestsPerTrial (7): Counter ← StandardTestsPerTrial,
    spying (8:0..0): BOOLEAN ← FALSE,
    spyOnProcs (8:1..1): BOOLEAN ← TRUE,
    showSpyData (8:2..15): {afterEachTest, afterAllTests} ← afterAllTests ];

  InitTestParameters: TestParameters = [];


-- Timers (they should be opaque, but that's even more clumsy than this).


  SystemTime: TYPE = LONG CARDINAL;  -- Same as System.Pulses.

  SystemTimer: PUBLIC TYPE = MACHINE DEPENDENT RECORD [
	start, event, elapsed: SystemTime ← 0,
	lastDelayFinished: SystemTime ← 0 ];

  InitSystemTimer: SystemTimer = [];


  PrecisionTime: TYPE = LONG CARDINAL;

  RingBufferIndex: TYPE = CARDINAL; --[0..tp.testsPerTrial);
  SortBufferIndex: TYPE = CARDINAL; --[0..LAST[RingBufferIndex]+2);
  RingBuffer: TYPE = LONG DESCRIPTOR FOR ARRAY RingBufferIndex OF PrecisionTime;
  SortBuffer: TYPE = RECORD [SEQUENCE length: SortBufferIndex OF PrecisionTime] ;

  PrecisionTimer: PUBLIC TYPE = MACHINE DEPENDENT RECORD [
	start: PrecisionTime ← 0,
	ringIndex: RingBufferIndex ← 0,
	ringBuffer: RingBuffer ← NIL,
	sortBuffer: LONG POINTER TO SortBuffer ← NIL ];

  InitPrecisionTimer: PrecisionTimer = [];



-- Exerciser instance data.

  ExerciseHandle: TYPE = POINTER TO ExerciseObject;

  ExerciseObject: TYPE = RECORD [
	tp: TestParameters ← InitTestParameters,
	precisionTimer: PrecisionTimer ← InitPrecisionTimer,
	timer: SystemTimer ← InitSystemTimer,
	logStream: TTY.Handle ← ,
	logPut: PROC [CHARACTER] ← NIL ];


-- Internal operations.


  CheckAbort: PROC [self: Handle];

  SpyOperation: TYPE = {
    startAndWatchProcs, startAndWatchModules,
    startSpying, stopSpying, displayStats,
    stop, stopAndDisplayStats };

  CallSpy: PROCEDURE [
	self: Handle,
	operation: SpyOperation ];

  InitPrecisionTimings: PROCEDURE [self: Handle];
  FinishPrecisionTimings: PROCEDURE [self: Handle];


END.  -- LupineExerciserPrivate.