Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 |
/////////////////////////////////////////////////////////// // FPSLog UnrealScript Class created by // by Marco Zaratti - marco.zaratti@gmail.com // //--Abstract----------------------------------------------- // This class is an Actor placeable in a map that logs // frame rate in "FPSStats.txt" in /UserLog dir. // It is useful to trace performance graphs. "FPSStats.txt" // may be imported in Excel (for instance) where a graph // can be created in just few mouse clicks. //--------------------------------------------------------- // //--How To Use--------------------------------------------- // Just place the Actor FPSLog in your map. // FPSStats.txt is written when UT Client is closed and its // output looks like (for each sample): // // time, FPS, delta (=1/FPS), counter // // time: is the total time passed // FPS: is the frame rate // delta: is the the last frame computation time (=1/FPS) // counter: is e generic counter increased and decreased by // triggering or untriggering FPSLog // // counter may be used to count the number of robots in the map // or for any other purpose. To count the number of robots you // should add some code to your robot class or to KRobot to // trigger and untrigger FPSLog. // // Sample rate may be choosen with maxSamplesSec variable, // for example: // maxSamplesSec=1 mens 1 sample/sec // maxSamplesSec=10 means 10 samples/sec // // This variable may be specified in the defaultproperties, // in the FPSLog properties edited in UnrealEd or in *.INI file. // In *.INI use this syntax: // [USARBot.FPSLog] // maxSamplesSec=10 // // A final note: UT opens FPSStats.txt in append mode, so // erase it if you want a new data set. //--------------------------------------------------------- // /////////////////////////////////////////////////////////// class FPSLog extends Actor config(USARBot) Placeable; /////////////////////////////////////////////////////////// // FPSLog variables var FileLog logger; var() config int maxSamplesSec; //max num of samples/sec var float maxResolution; var float timeTotal; var float timeDelta; var int tickCounter; /////////////////////////////////////////////////////////// // Activation variables enum LogMode{FPS_OFF, FPS_ON, FPS_TRIGGERED}; //possible states var() config LogMode FPSLogMode; //Used to choose initialstate (needed for USAR.INI) //used by LoggingTriggered var bool triggeredLog; //Saves triggered status var bool markTrigger; //Signals a TRIGGERED notification var float timeTrigger; //Elapsed time between triggers /////////////////////////////////////////////////////////// // Other variables var int eventCounter; //eache Trigger increases counter //eache UnTrigger decreases counter /////////////////////////////////////////////////////////// simulated function PostNetBeginPlay() { Super.PostNetBeginPlay(); maxResolution = 1.0/maxSamplesSec; timeTotal = 0.0; timeDelta = 0.0; tickCounter = 0; eventCounter = 0; triggeredLog=False; markTrigger=False; timeTrigger= 0.0; logger = Spawn(class'FileLog'); //Open FPS log file (will be placed in /UserLog): logger.OpenLog("FPSStats","txt"); } simulated event SetInitialState() { //We need FPSLogMode var if we want to set the state from USAR.INI switch(FPSLogMode) { case FPS_OFF: InitialState='LoggingOff';break; case FPS_ON: InitialState='LoggingOn';break; case FPS_TRIGGERED: InitialState='LoggingTriggered';break; default: InitialState='LoggingOff';break; } super.SetInitialState(); } simulated event Destroyed() { logger.CloseLog(); //Close FPS log file: Super.Destroyed(); } event Trigger( Actor Other, Pawn EventInstigator ) { eventCounter++; } event UnTrigger( Actor Other, Pawn EventInstigator ) { eventCounter--; if(eventCounter < 0) eventCounter = 0; } //+++++++++++++++++++++ STATE +++++++++++++++++++++++++++// // Log always state LoggingOn { simulated function Tick(float Delta) { local float fpsStat; local string outStr; Super.Tick(Delta); tickCounter++; timeTotal += Delta; timeDelta += Delta; if(timeDelta >= maxResolution) { fpsStat = tickCounter / timeDelta; timeDelta = (timeDelta / tickCounter)*1000; outStr = timeTotal $","$ fpsStat $","$ timeDelta $","$ eventCounter; logger.LogF(outStr); tickCounter = 0; timeDelta = 0.0; } } } //+++++++++++++++++++++ STATE +++++++++++++++++++++++++++// // Do not log state LoggingOff { ignores Trigger, UnTrigger; } //+++++++++++++++++++++ state +++++++++++++++++++++++++++// // Log only when eventCounter > 0 state LoggingTriggered { simulated function Tick(float Delta) { local float fpsStat; local string outStr; Super.Tick(Delta); if(triggeredLog) { if(eventCounter == 0) { triggeredLog = false; timeTrigger += timeDelta; tickCounter = 0; timeDelta = 0.0; } } else { timeTrigger += Delta; if(eventCounter > 0) { triggeredLog = true; markTrigger = true; //ADDS "TRIGGERED" to output sample } } if(triggeredLog) { tickCounter++; timeTotal += Delta; timeDelta += Delta; if(timeDelta >= maxResolution) { fpsStat = tickCounter / timeDelta; timeDelta = (timeDelta / tickCounter)*1000; outStr = timeTotal $","$ fpsStat $","$ timeDelta $","$ eventCounter; if(markTrigger) { outStr $= ",+"$ timeTrigger $",TRIGGERED"; markTrigger = false; } logger.LogF(outStr); tickCounter = 0; timeDelta = 0.0; } } } } defaultproperties { FPSLogMode=FPS_ON maxSamplesSec=2 bHidden=True Texture=Texture'Engine.S_Note' } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |