Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Measuring server frame time?
Re: Measuring server frame time? [message #492090 is a reply to message #492071] Wed, 15 March 2017 02:02 Go to previous messageGo to previous message
iRANian is currently offline  iRANian
Messages: 4299
Registered: April 2011
Karma:
General (4 Stars)
I'd start with just doing an OnThink() hook which writes to a dynamic vector of a struct FrameTime which looks like this:

struct FrameTime {
int frame;
int msDiffSinceLastFrame; // the milliseconds difference since last frame
}

In the init function of the plugin you initialize the dynamic vector class with type struct FrameTime and a global called FrameLastTime which stores the last frame time in milliseconds (the milliseconds expired since Windows was started). Use timeGetTime() to initialize this var. the The init function also needs to use timeBeginPeriod(1); to set the timer resolution to 1 millisecond.

In onThink you do:

int currentTimeInMs = timeGetTime();
int diffInMs = currentTimeInMs - FrameLastTime;
FrameLastTime = currentTimeInMs;

DynamicVectorClass.add( new FrameTime { .Frame = The_Game()->Get_Current_Frame(), .msDiffSinceLastFrame = diffInMs });


In the gameover hook you add:

Function_To_Write_CSV_File_From_Dynamic_Vector_Of_FrameTimes();
for each FrameTime in DynamicVectorClass_Of_FrameTImes
-->delete FrameTime;
DynamicVectorClass_Of_Frame_Times.Clear();

The function to write frametimes just does a for each loop on every the dynamic vector of frame times and does a fprintf(file, "%d,%d", FrameTime->frame, FrameTime->msDiffSinceLastFrame);

Don't forget to call fopen() and fclose(). the filename should contain the start date and time of the map, map name etc.

Then you open the .csv text file that is written and create a graph in Excel or something.

Main issue is that the Windows timer functions we're using might not be high resolution enough...the Microsoft documentation is warning about it. We can use more high resolution timers if that's an issue.

Another issue is that the timeGetTime() functions returns the milliseconds since Windows was started, as a 32-bit value. This wraps around after Windows has been running for 48 days (so after 48 days, timeGetTime() will start returning from 0)




Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Wed, 15 March 2017 02:03]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: *wip* renegade coop
Next Topic: Where does the server or client do the always.dat version check?
Goto Forum:
  


Current Time: Tue May 14 17:29:35 MST 2024

Total time taken to generate the page: 0.00783 seconds