DIRECTORY Convert, DynaStats, DynaSeer, Histograms, IO, ViewerClasses; DynaStatsImpl: CEDAR PROGRAM IMPORTS Convert, DynaSeer, Histograms, IO EXPORTS DynaStats = BEGIN OPEN DynaStats; Stats: TYPE = REF StatsRec; StatsRec: TYPE = RECORD [ numberOfOccupiedCycles, numberOfBubbles, numberOfNoOps: INT _ 0, numberOfRequests, numberOfDisplayRequests, numberOfCacheRequests: INT _ 0, numberOfRBRqst, numberOfWBRqst, numberOfWSRqst: INT _ 0, numberOfReplys, numberOfDisplayReplys, numberOfCacheReplys: INT _ 0, grantLatencyHisto, replyLatencyHisto: Histograms.Histogram _ NIL, grantLatencyViewer, replyLatencyViewer: ViewerClasses.Viewer _ NIL ]; Init: PUBLIC PROC [handle: Handle] ~ { stats: Stats _ NEW [StatsRec]; stats.numberOfOccupiedCycles _ stats.numberOfBubbles _ stats.numberOfNoOps _ 0; stats.numberOfRequests _ stats.numberOfDisplayRequests _ stats.numberOfCacheRequests _ 0; stats.numberOfRBRqst _ stats.numberOfWBRqst _ stats.numberOfWSRqst _ 0; stats.numberOfReplys _ stats.numberOfDisplayReplys _ stats.numberOfCacheReplys _ 0; stats.grantLatencyHisto _ Histograms.Create1D[]; stats.replyLatencyHisto _ Histograms.Create1D[]; stats.grantLatencyViewer _ Histograms.Show[h: stats.grantLatencyHisto, viewerInit: [name: "Grant Latency"], updatePeriod: 4]; stats.replyLatencyViewer _ Histograms.Show[h: stats.replyLatencyHisto, viewerInit: [name: "Reply Latency"], updatePeriod: 4]; handle.stats _ stats; }; PrintIt: PUBLIC PROC [handle: Handle] RETURNS [BOOL] = { RETURN [handle.numCycles <= 500] }; AddToHistory: PUBLIC PROC [handle: Handle, cycle: Cycle] = { stats: Stats _ NARROW[handle.stats]; IF PrintIt[handle] THEN PrintCycle[handle, cycle]; IF DynaSeer.IsUsefulCycle[cycle] THEN stats.numberOfOccupiedCycles _ stats.numberOfOccupiedCycles+1; IF cycle.cmd=Bubble THEN stats.numberOfBubbles _ stats.numberOfBubbles+1; IF cycle.cmd=NoOp THEN stats.numberOfNoOps _ stats.numberOfNoOps+1; IF DynaSeer.IsRequestCycle[cycle] THEN { stats.numberOfRequests _ stats.numberOfRequests+1; IF DynaSeer.IsDisplay[handle, cycle.deviceId] THEN stats.numberOfDisplayRequests _ stats.numberOfDisplayRequests+1; IF DynaSeer.IsCache[handle, cycle.deviceId] THEN stats.numberOfCacheRequests _ stats.numberOfCacheRequests+1; IF cycle.cmd=RBRqst THEN stats.numberOfRBRqst _ stats.numberOfRBRqst+1; IF cycle.cmd=WBRqst THEN stats.numberOfWBRqst _ stats.numberOfWBRqst+1; IF cycle.cmd=WSRqst THEN stats.numberOfWSRqst _ stats.numberOfWSRqst+1; }; IF DynaSeer.IsReplyCycle[cycle] THEN { stats.numberOfReplys _ stats.numberOfReplys+1; IF DynaSeer.IsDisplay[handle, cycle.deviceId] THEN stats.numberOfDisplayReplys _ stats.numberOfDisplayReplys+1; IF DynaSeer.IsCache[handle, cycle.deviceId] THEN stats.numberOfCacheReplys _ stats.numberOfCacheReplys+1; }; IF ~DynaSeer.IsDataCycle[cycle] THEN handle.lastNonDataCycle _ cycle; IF DynaSeer.IsHeaderCycle[cycle] THEN Histograms.Increment[stats.grantLatencyHisto, cycle.grantLatency]; IF DynaSeer.IsReplyCycle[cycle] THEN Histograms.Increment[stats.replyLatencyHisto, ReplyLatency[cycle, handle.history]]; handle.history _ CONS[cycle, handle.history]; }; ReplyLatency: PROC [cycle: Cycle, history: Cycles] RETURNS [latency: NAT _ 0] ~ { FOR h: Cycles _ history, h.rest WHILE h#NIL DO latency _ latency+1; IF cycle.data=h.first.data AND cycle.deviceId=h.first.deviceId THEN RETURN [latency] ENDLOOP; ERROR; }; PrintStats: PUBLIC PROC [handle: Handle] ~ { stats: Stats _ NARROW[handle.stats]; IO.PutF[handle.out, "\n\n\nTotal Number of Cycles: %g", IO.int[handle.cycleNumber-1]]; IO.PutF[handle.out, "\n Number Occupied: %g", IO.int[stats.numberOfOccupiedCycles]]; IO.PutF[handle.out, "\n Number of Bubbles: %g", IO.int[stats.numberOfBubbles]]; IO.PutF[handle.out, "\n Number of NoOps: %g", IO.int[stats.numberOfNoOps]]; IO.PutF[handle.out, "\nNumber of requests: %g", IO.int[stats.numberOfRequests]]; IO.PutF[handle.out, "\n Number from display: %g", IO.int[stats.numberOfDisplayRequests]]; IO.PutF[handle.out, "\n Number from caches: %g", IO.int[stats.numberOfCacheRequests]]; IO.PutF[handle.out, "\nNumber of replys: %g (+%g pending in memory queues)", IO.int[stats.numberOfReplys], IO.int[stats.numberOfRequests-stats.numberOfReplys]]; IO.PutF[handle.out, "\n Number to display: %g", IO.int[stats.numberOfDisplayReplys]]; IO.PutF[handle.out, "\n Number to caches: %g", IO.int[stats.numberOfCacheReplys]]; IO.PutF[handle.out, "\nNumber of RBRqst: %g", IO.int[stats.numberOfRBRqst]]; IO.PutF[handle.out, "\nNumber of WBRqst: %g", IO.int[stats.numberOfWBRqst]]; IO.PutF[handle.out, "\nNumber of WSRqst: %g", IO.int[stats.numberOfWSRqst]]; }; PrintCycle: PROC [handle: Handle, cycle: Cycle] = { PrintCmd: PROC [cmd: Cmd] = { SELECT cmd FROM NoOp => IO.PutRope[handle.out, " NoOp "]; DataCycle => IO.PutRope[handle.out, "DataCycle "]; Bubble => IO.PutRope[handle.out, " Bubble "]; RBRqst => IO.PutRope[handle.out, "RBRqst "]; RBRply => IO.PutRope[handle.out, "RBRply "]; WBRqst => IO.PutRope[handle.out, "WBRqst "]; WBRply => IO.PutRope[handle.out, "WBRply "]; WSRqst => IO.PutRope[handle.out, "WSRqst "]; WSRply => IO.PutRope[handle.out, "WSRply "] ENDCASE => ERROR; }; PrintDeviceId: PROC[id: DeviceId] = { IO.PutRope[handle.out, Convert.RopeFromInt[id]]; }; IO.PutRope[handle.out, "\nCycle "]; IO.PutRope[handle.out, Convert.RopeFromInt[handle.cycleNumber]]; IO.PutRope[handle.out, " "]; PrintCmd[cycle.cmd]; IF cycle.cmd=NoOp OR cycle.cmd=DataCycle OR cycle.cmd=Bubble THEN RETURN; IO.PutRope[handle.out, " DeviceId="]; PrintDeviceId[cycle.deviceId]; IO.PutRope[handle.out, " Master="]; PrintDeviceId[cycle.master]; IO.PutRope[handle.out, " Data="]; IO.PutRope[handle.out, Convert.RopeFromInt[cycle.data]]; IO.PutRope[handle.out, " GrantLatency="]; IO.PutRope[handle.out, Convert.RopeFromInt[cycle.grantLatency]]; }; END. DynaStatsImpl.mesa Copyright c 1986 by Xerox Corporation. All rights reserved. Written By: Pradeep Sindhu September 18, 1986 4:52:07 pm PDT Pradeep Sindhu September 26, 1986 11:49:39 pm PDT Last Edited by: Louis Monier September 24, 1986 5:53:56 pm PDT Κ$– "cedar" style˜codešœ™Kšœ Οmœ1™K™—KšΟk œ,žœ˜GJ˜•StartOfExpansion[]šΟn œžœž˜Kšžœ ž˜)Kšžœ ˜Kšžœžœ ˜—K˜Kšœžœžœ ˜šœ žœžœ˜Kšœ8žœ˜@KšœBžœ˜JKšœ0žœ˜8Kšœ<žœ˜DKšœ=žœ˜AKšœ?ž˜BK˜—K˜šŸœž œ˜&Kšœžœ ˜K˜KšœO˜OKšœY˜YKšœG˜GKšœS˜SKšœ0˜0Kšœ0˜0Kšœ}˜}Kšœ}˜}K˜K˜—K˜š Ÿœžœžœžœžœ˜8Kšžœ˜ K˜—K˜K˜šŸ œžœžœ#˜˜@Kšžœ˜Jšœ˜Jš žœžœžœžœžœ˜IJšžœB˜DJšžœ>˜@Jšžœ˜!Jšžœ6˜8Jšžœ'˜)Jšžœ>˜@K˜—K˜K˜Kšžœ˜K˜—…—”Ύ