Thank you for your reply. I add these code above in my the function onWorldInitialized(), However,
// Get the number of the last processed frame and check if it is valid (just for sure) int64 LastGoodGameFrame = Stats.GetLastFullFrameProcessed(); if (Stats.IsFrameValid(LastGoodGameFrame) == false) { return; }
The code always return here ,it seems the frame is not vaild,unfortunately I can’t find the reason so far
Now I got it, “stat fps” seems does’t change the frame,so the frame value always -1. I change to “stat memory” just working well.
Hey, good to hear You’ve got it! I think the GetLastFullFrameProcessed() returns the valid frame only if the specific stat group is active. For measuring fps I recommend to simply use
int FPS = (int)(1.f / DeltaTime);
somewhere in global tick function, for example in GameMode.
I know the function will should work for stat groups that are displayed in the form of a table on the screen.
Anyway - good it’s still working
Thank you for posting this! It’s working well for me. I am trying to automate some tests by calling these commands from a Python script. Your code works great. I am having trouble getting the stat particles and stat gpu commands to work, though. What do you mean by “running it on Game Thread”? I am seeing warnings like this…
LogStats: Warning: There is no thread with id: 5792. Please add thread metadata for this thread.
when I run stat particles for the first time in a newly opened Editor.
Anyone who knows where to add the code above? I added them in Actor construct function and can not get stat data. I can see the warnings like this:
LogStats: Warning: There is no thread with id: xxx. Please add thread metadata for this thread.
I don’t know how to fix it.
I made a new .cpp and a new .h file. I put them in MyGame/Source/MyGame. Here is a thread about that warning you mentioned…
Thank you for reply! My problem is I don’t know how to call the function.
I called it from Python. It’s weird, but to access C++ methods from the Output Log Python command line you have to change the name. Here’s an example of calling a C++ method from the Python command line in the Output Log…
unreal.My_CPP_Class().write_stats()
…where the method in the C++ file is actually named My_CPP_Class::WriteStats()
Thank you again! My problem has been solved. I can get the data now.
Hey @zompi2 sorry for the 7 year later answer. (lol)
I am using your function to gather stats information, the thing is, it works only with Counters and Memory stats, not for Timer stats (in the NonStackStats
variable there are no Timer stats).
Do you remember why?