Closed duralakun closed 5 years ago
maybe i should rename fps to tps?
Is the place where you measure relevant? For example does the code return the same fps if I put it into gameworld.CPP ontick() function?
Why is it defined in server.cpp?
I think this is the main loop of the server, inside of it GameServer()->OnTick();
will also be called.
But you could easily create another CMeasureTicks anywhere else in the code to measure that part.
You can do it like this:
#include <engine/server/measure_ticks.h>
CMeasureTicks MeasureTicks = new CMeasureTicks(10, "Tag"); // to create an object, 10 seconds interval log
MeasureTicks.Begin(); // when the tick starts
MeasureTicks.End(); // when the tick ends
After last commit, the output now looks like this for me:
[5c6b8e1d][ServerTick]: 192fps, AverageTickTime: 5.192064ms, LongestTick: 5.486300ms [5c6b8e27][ServerTick]: 192fps, AverageTickTime: 5.188971ms, LongestTick: 5.518902ms [5c6b8e31][ServerTick]: 192fps, AverageTickTime: 5.201708ms, LongestTick: 5.292991ms
You can see the AverageTickTime is by 5ms longer. It is because i moved the end of tick function down to include the network waiting, which takes 5ms. This makes it less confusing, now 5.201708ms * 192fps = 1 second
i7 6700k 4.7 Ghz, No matter what I do InGame fps are constant! [5c6bb777][GameworldTick]: 50fps, AverageTickTime: 0.403353ms, LongestTick: 2.790882ms [5c6bb79f][GameworldTick]: 50fps, AverageTickTime: 0.278836ms, LongestTick: 5.439547ms [5c6bb7a9][GameworldTick]: 50fps, AverageTickTime: 0.616413ms, LongestTick: 4.481750ms [5c6bb7b3][GameworldTick]: 50fps, AverageTickTime: 0.420286ms, LongestTick: 3.696510ms [5c6bb7bd][GameworldTick]: 50fps, AverageTickTime: 0.064765ms, LongestTick: 0.590548ms
[5c6bbac6][GameServerTick]: 49fps, AverageTickTime: 0.173201ms, LongestTick: 2.603217ms [5c6bbae4][GameServerTick]: 50fps, AverageTickTime: 0.118468ms, LongestTick: 0.300982ms [5c6bbaee][GameServerTick]: 50fps, AverageTickTime: 0.417998ms, LongestTick: 3.382387ms [5c6bbaf8][GameServerTick]: 50fps, AverageTickTime: 0.468482ms, LongestTick: 2.778332ms [5c6bbb02][GameServerTick]: 50fps, AverageTickTime: 0.511107ms, LongestTick: 1.972839ms [5c6bbb0c][GameServerTick]: 50fps, AverageTickTime: 0.516488ms, LongestTick: 2.084371ms
This should be save to merge, because this feature is disabled by default, only when you uncomment defines it will be activated. The only other thing this pr does is deleting obsolete code. I searched with grep for uses of it and couldn't find any.
Allows you to measure how many ticks per second the server has.
Example output:
Right now every 10 seconds 1 line be logged