PerfStats.mesaPerfStatsisapackageusedforgatheringperformanceinformation,ofteninthecontextofatestprogram.Itimplementscountersandstopwatch-liketimers,andwillprintsummarystatisticstoastream.Lasteditedby:MBrownonAugust26,19829:12pmDIRECTORYIOUSING[STREAM],RopeUSING[ROPE];PerfStats:CEDARDEFINITIONS=BEGINROPE:TYPE=Rope.ROPE;STREAM:TYPE=IO.STREAM;Counter:TYPE=REFCounterObject;CounterObject:PRIVATETYPE=RECORD[pName:ROPE,counter:LONGCARDINAL_NULL,next:Counter];DefinedheresowecanuseaninlineforInc.CreateCounter:PROC[name:ROPE]RETURNS[Counter];DuplicateName:ERROR;RaisedonCreateCounterorCreateTimerifnamematchesanexistingevent'sname.InitializeCounter:PROC[event:Counter];DestroyCounter:PROC[event:Counter];Inc:PROC[event:Counter]=INLINE{event.counter_event.counter+1};Timer:TYPE=REFTimerObject;TimerObject:TYPE;CreateTimer:PROC[name:ROPE]RETURNS[Timer];InitializeTimer:PROC[event:Timer];DestroyTimer:PROC[event:Timer];Start:PROC[event:Timer];Stop:PROC[event:Timer];Initialize:PROC[];Initializesallevents.Print:PROC[heading:ROPE_NIL,oStream:STREAM,verbose:BOOL_FALSE];PrintscurrentstateofstatsmoduletoputChar,thencallscleanupifnotNIL;resetsglitchcount.Ifverbosethenprintsallevents,otherwiseonlyeventswithnonzerocounts.END.HowtousePerfStatseventsPerfStatsdefinestwotypesof"event":counterandtimer.EacheventhasaROPEname,suppliedwhentheeventiscreated(CreateCounter,CreateTimer)andusedtoidentifytheeventinprintedoutput.An1pî ìïa¶ qî ìï]ˆî×îBîvî·îÇîîî"ñ î*¢ î2Lî5¸î7]î9©î>xî@îAOîCÒî ìï[áî { î‹îéî� î#hî'Ñî*tî- î0Tî6 î;“î=8î>lî ýïZ1îîîïX�îµî¨îHî…îËî"Úrî ýïU!îïSqî¾sîíïSqrîQïSqsîïSqî~ïSqîïQÁrîÃïQÁî©ïQÁsîòïQÁrîUïQÁsîgïQÁîÊïQÁî ýïNa rî>ïNaî ïNaî¹ sî¾ïNarîïL±îïKsîïKrîïKîÖïKsîtïKîYïKrîáïKîµïKsîóïKrîïIQsîÙïIQrîÖïIQî�ïIQsî-ïIQrîïIQî|ïIQsîYïIQrî°ïIQsîzïIQîïEñrîëïEñî¤ïEñsîBïEñrî'ïEñîûïEñsî×ïEñîÕïEñ îïDA rîØïDAîïDAî8sî �ïDArî"tïDAî#HïDAsî'ÌïDAîïB‘rî{ïB‘îOïB‘sî�ïB‘îiïB‘rîãïB‘îœïB‘î"¹sî)ZïB‘rî*çïB‘î+ÏïB‘sî.'ïB‘î/ïB‘î2Œqî1ï@áî?î:îóîúî ˆî"èî$Ûî(¡î*Ètîï=� sîÂï=�rîÀï=�îgï=�sîMï=�î°ï=�rîéï=�î ½ï=�sî"úï=�rî#áï=�î$µï=�sî)Òï=�î*5ï=�îï;Ð rîkï;Ðî$ï;Ðsî}ï;Ðqîï: î…îx î�î!F î)"î*xî.î3Nî5Aî:Qî>±tîï8psî ï8prî ï8pî±ï8psî–ï8pîùï8pî!'tîï6À sî}ï6Àrîzï6Àî"ï6Àsîï6Àîjï6Àî ™tîï5sîóï5rîñï5î˜ï5sî}ï5îáï5îîÕrî ºï5î!$ï5sî%;ï5î%ìï5 î.tî0 î8Šî:oîï1°rîªï1°îcï1°sîï1°rîæï1°îºï1°sî–ï1°î~ï1° îï0 rî—ï0îPï0sî„ï0tîï,  sî�ï, rîŒï, î4ï, sîï, î|ï, rîµï, î‰ï, sî!Æï, rî"®ï, î#�ï, sî(Ÿï, î)ï, tîï*ðsîØï*ðrîÖï*ðî}ï*ðsîbï*ðîÆï*ðîôtîï)@ sîIï)@rîGï)@îîï)@sîÔï)@î7ï)@îetîï'�sîï'�rîï'�î·ï'�sî�ï'�îï'�î.tîï%àsîÐï%àrîÎï%àîuï%àsîZï%àî½ï%àîìtîï Ð sîDï ÐrîAï Ðîéï Ðsîdï ÐîÈï Ðqîï îdî_tîïpsîïprîïpî·ïpsîœïpîÿïprî°ïpî„ïpsî+ïprî ¸ïpî! ïpsî"Ãïpî# ïprî)‡ïpî*&ïpsî.Qïpî/.ïprî4²ïpî5kïpsî8Gïprî9Ôïpî:�ïpsî=rïpî=ÕïpqîïÀî&îÔîî«î Éî%î'$î,Ìî/×î2ñî7êî9Aî;¤î?CîBúîSïîêîxî!7î$Aî(î* î.kî4Vî7Rî;Yî>UîCqrîïisî–ïipî ìïgî�îÛuî ìï6î6qî ìï Üîëî~îî›îRî!Äî&²î)iî-úî1�î5%î7®vî8÷ï Üî9Áï Üqî<“ï Üî=Rï Üî@£îEïî ìï 5î WîùîƒîKî Q î(Åî+‡î.¶î0yî5pî7Ûî;}î=AîAöîGNwî)Èïöÿ‚TVm$attempttocreateaneventwiththesamenameasanexistingeventwillERRORDuplicateName.Countereventsareusedforloggingthefreqencywithwhichaspecificactionorsetofactionsisperformed.IfeisaPerfStats.Counter,thene.Inc[]causese'scountertobeincrementedby1.e.Inc[]isveryinexpensivetoperform.Timereventsareusedforloggingthetimerequiredforaspecificactionorsetofactions.IfeisaPerfStats.Timer,thene.Start[]recordsthecurrenttimeinavariableassociatedwithe.Thenwhene.Stop[]isperformedatsomelatertime,itnotesthedifferencebetweenthecurrenttimeandthetimerecordedbythepreviouse.Start[].Atpresenttheaverage,maximum,andminimumtimesaremaintainedinthetimerevent.e.Start[]ande.Stop[]involveoneprocedurecalleach,andmustreadtheprocessorclockandmanipulatee'sstatistics;hencetheyaremoreexpensivethane.Inc[].OntheDorado,thetimerresolutionis32microseconds,andthecostofaStart-Stoppairisabout33microseconds.OntheDolphinthesetimesare64microsecondsand417microseconds,respectively.AcalltoPerfStats.PrintprintsthecurrentstateofallactiveeventstoanoutputIO.STREAMcalledoStream.(Actually,unlessitsparameterverboseisTRUE,PrintprintsnothingforcounterswithnoInccallsandtimerswithnoStart-Stopcalls.)PrinttakesaROPEcalledheadingasaparameter,andprintsitaspartoftheoutput.PrintcallsoStream.FlushwhenitisthroughsendingcharacterstooStream.PrintistheonlywaytogetinformationoutofPerfStats;thereisnowaytointerrogateaneventdirectly.Whentwocallstoe.Start[]occurinsuccessionwithnointerveninge.Stop[],thefirste.Start[]isignored;whentwocallstoe.Stop[]occurconsecutively,thelastisignored.Eachofthesesituationscountsasa"glitch",andthenumberofglitchesisreportedfordebuggingpurposesduringPrint.GlitchesmayoccureveninprogramswhosecallstoStartandStopappeartomatchproperly,duetoafailuretocalle.Stop[]duringtheunwindofaprocedureactivationthatcallede.Start[].WeconsiderittoocumbersometoprovideacatchforUNWINDsimplytoavoidglitches,sowerecoverfromthemwithonlyaprintedwarning.Aseparateprocedure,PerfStats.Initialize,isprovidedinordertoresetallevents(clearsallcounters,forgetsalltimes,exceptthatthestartingtimeofarunningtimerisnotforgotten).Individualeventsmayalsobeinitialized(e.InitializeCounter[],e.InitializeTimer[]).Aneventiseliminatedbycallingadestroyprocedure(e.DestroyCounter[],e.DestroyTimer[].)ThisremovestheeventfromconsiderationbyPrint,andmakesitsstoragereclaimable.AnexampleTocompileaprogramthatusesthePerfStatspackage,importthePerfStatsdefinitionsmodule.Tobindtheprogram,usetheimplementationPerfStatsImplandimportIO,RopeandSystemforitsuse.ThefollowingistheskeletonofatestprogramthatusesthePerfStatspackage.DIRECTORYPerfStats,...SampleTest:PROGRAMIMPORTSPerfStats,...=BEGINoStream:IO.STREAM=...;insertCounter:PerfStats.Counter=PerfStats.CreateCounter["callstoInsert"];lookupTimer:PerfStats.Timer=PerfStats.CreateTimer["callstoLookup"];...Insert:PROC[x:Widget]={insertCounter.Inc[];...};--InsertLookup:PROC[k:WidgetKey]RETURNS[x:Widget]={lookupTimer.Start[];...2qî ìïb&îÒîwîqîdîèîäî0î"šî&>î'÷î)êî.ùî2}vî5ïb&î5Õïb&qî9|ïb&î:�ïb& î ìï_—î îîiîpîŽîPî!’î&åî)Øî-²î.Ýî3’î7›î9Kî;Uî<ïîA|îBÞ î ìï]ðî _î bî ³îÌîîôî!!î%5î'î+Ôî-^î/ î6‚î8@î:î>Gî?˜îB` î ìï\Iî ‘î ìïYºî$îaîéî.îŠî‰î" î%Fî*¾î-î.ƒî3vî7¼î9©î;ñî=ÉîC¤îEgîFºîHZî ìïXîüîûî5î Ñî#î'´î*±î,Lî-uî2€ î8Ìî;¼î=¡îAîDŽî ìïVkî aîÂîpîâîî|îÜî"hî$½ î*éî0 î2bî7î:+î<×î?,îB=îGµî ìïTÄî 9î~ î¢î–î9î †î%Êî,�î/&î5/î8½î; îB îCµîFî ìïSîÂîAî î\î! î#éî*Oî- î0Úî3¹î7?î:~î=îCîFëî ìïQu îþî îîî î"{î%þî,%î/^vî4µïQuî5’ïQuî6©î8“î<Óî>¾îA© îF¹îGðî ìïOÎ î¶îÍîžîÏîî îÊî�îî!Pî"nî%jî&é î.î/ðî1Áî5ëî8¡î;sî=Jî>É îELîGcî ìïN' î» qîïN'î ìïK˜î [î Þîpî�îYî“î#.î&Oî'ßî)Çî-�î1‚î3î4ôvî9ïK˜î9›ïK˜qî?ëïK˜î@†ïK˜îC¹î ìïIñ îEîlîjîåî!Åvî#RïIñî$ ïIñqî&uïIñî'sïIñî+î/î4î6dî;äî?îAîC°îFëî ìïHIî úîòîâîTîNî}îæî"dî%ìvî'ïHIî'èïHIqî*§ïHIî+BïHIî.…î3�î5Fî6w î=&î?ÆîC’îDæîFœî ìïF¢î ¡î þî<îÏîú î#î&šî(î)€î.¡î3— î:î;ÍîB3îEÆîGCî ìïDûî èî©îNîŽ îàîAîå î%Iî(µî* î,î.Õî0z î7Pî9Cî<Çî ìïBlî ÷î’î¼îpîÄîî 5 î&µî)Àî+ î2Íî86î:‘î=pîBÄîD?î ìï@Åî Šî2îhî)îFî î&™î)î+©î-1î3î6·î8wî;þ îB*îF…îHZî ìï?îqîîuîcîîüî!rî&¿î(ñî/jî4íî9?î=±îBêîEãî ìï=vî î°î�î›îºîdî ßî#ˆî&¾î+)î,Óî0êî6‰î9î:Äî;þî@IîAóîDŽî ìï;Ïî#î^îî˜î»îÖ î#õî&¶î*† î0…î2ôî8(î9nî;³ îCHîDÜî ìï:'î !î¸vîàï:'î¼ï:'qîQï:'îÖï:'îŒî1îÄî$þî&·î(¾î-gî0¤î4î7î9þî;3î?Éî ìï7™î aî˜ îî"Úî$9î)�î+)î.¥î0=î3cî5Qî9Lî=�î?}îE'î ìï5ñî èîÍî îÝî)îî!#î"Çî#üî)î,Ÿî. î0o î7ˆ î=ùîBîDòîG¿î ìï4J î%î?î ìï1»î "î›îü îzîJî§îÑî#dî)…î5ÕîAfîDkî ìï0î 8î¼îù î1î î åî#‰î'ºî)•î.? uî ìï+×î �qî ìï(nî îîSîÂîžî�îãî%Ùî+~î/Ûî21î8' î>»îDbîFˆî ìï&Çî 8îõîUî¡ î  î(Îî+rvî/Åï&Çî0Aï&Çqî1ï&Çî1ùï&Çî5wî8î<Æî>îî@Êî ìï$8î ¯îƒîïî;î‚î&îZî Þî&Cî)î+ùî.Eî40vî ìï!ªqvî õïùî ®ïùqîGïùî õïGî ìï– vî²ï–îkï–îíî­qî!ÿï–î"Üï–î$ivî&Nï–î'ï–qî õïåvîÕïåîQïåqî°ïåvî•ïåîÛïåqîÒïåî õï4 vîàï4î™ï4qîyï4îwï4î¶vî›ï4î Tï4qî$4ï4î%1ï4î0ýî2¢î õïƒ vîjïƒî#ïƒqîïƒîêïƒîvîìïƒî¥ïƒqî"…ïƒî#‚ïƒî.î/ºî õïÑî õï vî_ï îï qîôï îcï î'îIî.î ýïo vîëïoqî2ïoî ýï¾î Š î õï \vîzï \î3ï \qîï \î}ï \îB vî­ï \îxï \qî#’ï \î$ï \î%Äî*æî,Ëî ýï ª vîuï ªqî»ï ªî ýï ùwî)Èïö NTVm$jlookupTimer.Stop[]};--Lookup...Test1[];--callsInsertandLookupPerfStats.Print["Test1",oStream];PerfStats.Initialize[];Test2[];--callsInsertandLookupPerfStats.Print["Test2",oStream];insertCounter.DestroyCounter[];lookupTimer.DestroyTimer[];END.--SampleTestChangeLogCreatedbyMBrownonNovember4,19803:35PMByeditingDBStats.ChangedbyMBrownonNovember7,19809:31AMAddInitializeCounterEventandInitializeTimerEvent.ChangedbyMBrownonJanuary10,19819:24PMCreatedPilot/collectiblestorageversion.PrintnowtakesputCharandcleanupasparms.RenamedtobePerfStats;madetypeandprocnameslessverbose.Movedmostcommentstodocumentationfile(PerfStats.bravo).ChangedbyMBrownonJanuary11,19814:46PMAddedDuplicateNameERROR.AddedverboseparmtoPrint.ChangedbyMBrownon18-Aug-8118:28:40CedarString->Rope.ChangedbyMBrownon7-Dec-8115:23:08UseIOStream,ROPE.ChangedbyMBrownonJune24,19821:16pmIOStream->IO,CEDAR.ChangedbyMBrownonAugust26,19829:21pmFormatinterfacewithnodestructure,mergedocumentationbackin.3qî ýïb& vîuïb&qî»ïb&îÉ î õï`î õï^×îöîîôî—vî õï]0î ®ï]0qî�ï]0îuï]0 î¤îâvî0ï]0îéï]0qî#Éï]0î$dï]0 î õï[‰îöîîôî—vî õïYáî ®ïYáqî�ïYáîuïYá î¤îâî õïX: vîâïX:qî)ïX:î õïV“ vîlïV“qî³ïV“vî ÀïTëqî ;ïTëî “ïTë pî ìïOõîëxî ìïKÓîîîÙîàî²î!?î% rî(ïKÓî(ÀïKÓqî ìïIXî î~xî ìïFÝî¾î¹îî…î Xî!åî%¯rî(¾ïFÝî)‘ïFÝqî ìïDbî ÏîŸîCxî ìïAçî¾î¹îî…î±î ïî$¹rî'ÈïAçî(oïAçqî ìï?lî÷îÁîhî"Õî&Uî).î,·î2î4§î9žî;Uî@1îFîG¿î ìï=Å î»î»î îî†î#î&î,}î1Vî4ÿî;³î= îG;î ìï<xî ìï9¢î¾î¹îî…î±î ïî$¹rî'Èï9¢î(oï9¢qî ìï7'î î°îî"?î&ýî*|î,!xî ìï4¬î¾î¹îî…î =qî ìï21 î‘î?xî ìï/¶î¾î¹îî…îmqî ìï-;î £î`xî ìï*Àî¾î¹îî…î×îî"Zî%iqî ìï(EîQîÿîŠxî ìï%Êî¾î¹îî…îCî €î#Æî&Õqî ìï#Oî¸îBî>î| î uî$z î-‰î0Ðwî)Èï¿TVm$Ó TIMESROMANþŸ HELVETICAþŸ TIMESROMANþæ TIMESROMANþY TIMESROMANþŸLAURELþŸ TIMESROMANþæ TIMESROMANþŸ TIMESROMANþ îLj/™•°-ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿperfstats.press26-Aug-82 21:40:13