How do I record and export performance statistics?

For my bachelor thesis I would like to statistically evaluate the performance of different scenes in my game. Ideally I would record the CPU and GPU frame times for exactly 1000 frames and store the results in a text file (e.g. results.csv) so I can plot them and compute their mean and standard deviation.

The stat startfile command would be ideal if I could find a way to parse its binary output files…

Isn’t there a way to export the data recorded by Unreal Insights (Tools->Unreal Insights)? Or could I somehow record performance statistics via C++?

The commands StartFPSChart and StopFPSChart and their corresponding C++ methods do exactly what I need.

In an AActor or UComponent subclass you can call

UGameplayStatics::GetGameInstance(this)->GetEngine()->StartFPSChart(Label, true);

in order to start recording performance statistics and

UGameplayStatics::GetGameInstance(this)->GetEngine()->StopFPSChart(WorldContextObject->GetWorld()->GetMapName());

in order to stop recording and saving the results to a CSV file.

source: