UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AndroidProfiler.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreTypes.h"
5#include "CoreMinimal.h"
6
7/*
8* Invokes android's built-in perfetto capture API.
9*
10* Usage:
11* FString ProfileName = FAndroidProfiler::StartCapture(ArgsString, [](const FAndroidProfiler::FProfileResults& Results)
12 {
13 // lambda to be called when capture completes.
14 // This can be called from a random thread.
15 // params:
16 // Results.ProfileName == the tag/name used when initiating the profiling session.
17 // Results.Error == Any errors or warnings generated during the session
18 // Results.FilePath == empty on error. otherwise contains the path to the perfetto capture.
19 // the file is in the apps internal files folder. it is up to the application
20 // to move or delete this file.
21 } );
22*
23* where ArgsString = "callstack [optional args]"
24* ArgsString = "heap [optional args]"
25* ArgsString = "system [optional args]"
26*
27* optional args can be any of the following (space delimited):
28*
29* duration=x (in seconds, default 10)
30* buffersize=x (in kb, default 1000)
31* profilename=x (unique name for the profile session, default 'profile')
32* (you cannot have concurrent sessions with the same name.)
33* samplingfreq=x (callstack profile only. number of samples per second, default 100)
34* samplingintervalbytes=x (heap profile only. alloc granularity of heap samples, default 100)
35* bufferfillpolicy=[ringbuffer|discard] (system profile only. default ringbuffer)
36*
37* example: callstack samplingfreq=1000 duration=30
38*
39* to stop an in progress capture:
40* param ProfileName is the name/tag of the profile to cancel (i.e. as returned from StartCapture)
41* FAndroidProfiler::StopCapture(ProfileName);
42*
43*/
44
46{
47public:
48
50 {
51 FString ProfileName;// string used to identify the profile session.
52 FString Error; // Any errors or warnings produced
53 FString FilePath; // path to any output produced. empty on error.
54 };
55
56 // Returns an FString used to identify the profile session.
57 static FString StartCapture(const FString& Args, TUniqueFunction<void(const FAndroidProfiler::FProfileResults& Results)> OnFinish);
58
59 // stop an in-progress profile session.
60 static void StopCapture(const FString& ProfileName);
61
62private:
63 static inline FCriticalSection ProfilerCS;
64
65 // Called when a profile session ends. (either on success or on error)
66 static void OnProfileFinish(const FAndroidProfiler::FProfileResults& Results);
67
68 struct FActiveSessions
69 {
70 TUniqueFunction<void(const FProfileResults& Results)> OnFinish;
71 };
72 static inline TMap<FString, FActiveSessions> ActiveSessions;
73
75};
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
Definition AndroidProfiler.h:46
static void StopCapture(const FString &ProfileName)
Definition AndroidProfiler.cpp:200
static FString StartCapture(const FString &Args, TUniqueFunction< void(const FAndroidProfiler::FProfileResults &Results)> OnFinish)
Definition AndroidProfiler.cpp:199
friend struct FAndroidProfilerInternal
Definition AndroidProfiler.h:74
Definition UnrealString.h.inl:34
Definition FunctionFwd.h:19
Definition AndroidProfiler.h:50
FString FilePath
Definition AndroidProfiler.h:53
FString ProfileName
Definition AndroidProfiler.h:51
FString Error
Definition AndroidProfiler.h:52