How do I record and export performance statistics?

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: