DIRECTORY BasicTime, Commander, IO, Process, Real, Rope, ViewerClasses, ViewerOps, ViewerPrivate; ViewersBenchmark: CEDAR PROGRAM IMPORTS BasicTime, Commander, IO, Process, Real, ViewerOps, ViewerPrivate = BEGIN ROPE: TYPE = Rope.ROPE; Viewer: TYPE = ViewerClasses.Viewer; OpNCloseCmd: PROC [cmd: Commander.Handle] RETURNS [result: REF ANY ¬ NIL, msg: ROPE ¬ NIL] --Commander.CommandProc-- = { cmdLineStream: IO.STREAM = IO.RIS[cmd.commandLine]; viewerName: ROPE = cmdLineStream.GetRopeLiteral[]; times: NAT = cmdLineStream.GetInt[]; pausePerCycle: REAL = cmdLineStream.GetReal[]; period: REAL = OpNClose[viewerName, times, pausePerCycle]; msg ¬ IO.PutFR1["period = %g", [real[period]]]; }; OpNClose: PROC [viewerName: ROPE ¬ "Finch", times: NAT ¬ 30, pausePerCycle: REAL ¬ 0.08, waitEveryCycle: BOOL ¬ TRUE] RETURNS [period: REAL] = { v: Viewer = ViewerOps.FindViewer[viewerName]; pauseTicks: Process.Ticks ¬ Process.MsecToTicks[Real.Round[1000*pausePerCycle]]; IF NOT v.iconic THEN ViewerOps.CloseViewer[v]; ViewerPrivate.WaitForPaintingToFinish[]; {start: BasicTime.Pulses = BasicTime.GetClockPulses[]; FOR i: NAT IN [0 .. times) DO ViewerOps.OpenIcon[v]; Process.Pause[pauseTicks]; IF waitEveryCycle THEN ViewerPrivate.WaitForPaintingToFinish[]; ViewerOps.CloseViewer[v]; Process.Pause[pauseTicks]; IF waitEveryCycle THEN ViewerPrivate.WaitForPaintingToFinish[]; ENDLOOP; ViewerPrivate.WaitForPaintingToFinish[]; {end: BasicTime.Pulses = BasicTime.GetClockPulses[]; period ¬ BasicTime.PulsesToSeconds[end-start]/times; }}}; Scroll: PROC [viewerName: ROPE ¬ "[Cedar]Documentation>TiogaDoc.tioga!1", fraction: REAL ¬ 0.667, pausePerCycle: REAL ¬ 0.08, waitEveryCycle: BOOL ¬ TRUE] RETURNS [total: REAL, times: NAT, perScroll: REAL] = { v: Viewer = ViewerOps.FindViewer[viewerName]; pauseTicks: Process.Ticks ¬ Process.MsecToTicks[Real.Round[1000*pausePerCycle]]; [] ¬ v.class.scroll[v, thumb, 0]; ViewerPrivate.WaitForPaintingToFinish[]; {start: BasicTime.Pulses = BasicTime.GetClockPulses[]; scrollAmt: NAT = Real.Round[v.ch*fraction]; times ¬ 0; WHILE v.class.scroll[v, query, 0].bottom < 99 DO [] ¬ v.class.scroll[v, up, scrollAmt]; Process.Pause[pauseTicks]; IF waitEveryCycle THEN ViewerPrivate.WaitForPaintingToFinish[]; times ¬ times + 1; ENDLOOP; ViewerPrivate.WaitForPaintingToFinish[]; {end: BasicTime.Pulses = BasicTime.GetClockPulses[]; total ¬ BasicTime.PulsesToSeconds[end-start]; perScroll ¬ total/times; }}}; Commander.Register["OpNClose", OpNCloseCmd, "OpNClose \"viewer name\" times pausePerCycle", NIL, FALSE]; END. † ViewersBenchmark.mesa Copyright Σ 1992 by Xerox Corporation. All rights reserved. Mike Spreitzer March 25, 1992 12:45 pm PST Κ—–(cedarcode) style•NewlineDelimiter ™code™Kšœ Οeœ1™