Google.Android.PerformanceTuner.AndroidPerformanceTuner< TFidelity, TAnnotation >

The main class to instantiate to set up and run the Android Performance Tuner.

Summary

Details
Template Parameters
TFidelity
FidelityParams message class generated by the plugin.
TAnnotation
Annotation message class generated by the plugin.

Public attributes

onReceiveFidelityParameters
Action< TFidelity >
Action called every time new fidelity parameters are set.
onReceiveUploadLog
Action< UploadTelemetryRequest >
Action called every time log is uploaded.

Public functions

EnableLocalEndpoint()
Enable local endpoint.
EnableMemoryRecording(bool enabled)
Enable or disable memory telemetry recording.
EnableUploadCallback()
Enable upload callback.
FindFidelityParametersInApk(string filename)
Result< TFidelity >
Load fidelity parameters from the APK "assets/tuningfork/" folder.
Flush()
Force upload of the current histograms.
FrameTick(InstrumentationKeys key)
Record a frame tick that will be associated with the instrumentation key and the current annotation.
GetFidelityParameters(TFidelity defaultFidelity, uint initialTimeoutMs)
Result< TFidelity >
A blocking call to get fidelity parameters from the server.
SetCurrentAnnotation(TAnnotation annotation)
Set the current annotation.
SetFidelityParameters(TFidelity fidelityParams)
Set the currently active fidelity parameters.
SetLoadingState(MessageUtil.LoadingState state)
Set loading state.
SetMetricLimits(MetricLimits metricLimits)
void
Set metric limits.
Start()
Start AndroidPerformanceTuner.
StartLoadingGroup(LoadingTimeMetadata eventMetadata, TAnnotation annotation)
Result< ulong >
Start a loading group.
StartRecordingLoadingTime(LoadingTimeMetadata eventMetadata, TAnnotation annotation)
Result< ulong >
Record the start of a loading event.
Stop()
Stop Android Performance Tuner.
StopLoadingGroup(ulong handle)
Stop recording events as belonging to a group and record a group event.
StopRecordingLoadingTime(ulong handle)
Record the end of a loading event.
SwappyIsEnabled()
bool
Return if swappy is enabled or not.

Public attributes

onReceiveFidelityParameters

Action< TFidelity > onReceiveFidelityParameters

Action called every time new fidelity parameters are set.

onReceiveUploadLog

Action< UploadTelemetryRequest > onReceiveUploadLog

Action called every time log is uploaded.

Public functions

EnableLocalEndpoint

ErrorCode EnableLocalEndpoint()

Enable local endpoint.

Available for debug builds only. Check README or integration guide for more details how to enable local end point.

Details
Returns
ErrorCode.InvalidMode if using in non-debug build.

EnableMemoryRecording

ErrorCode EnableMemoryRecording(
  bool enabled
)

Enable or disable memory telemetry recording.

By default, memory telemetry recording is turned off at initialization and currently the memory statistics are not shown in the Google Play Console. It is not recommended to enable it.

Details
Parameters
enabled
If true, memory recording is enabled, if false it is disabled
Returns
ErrorCode.Ok if memory recording successfully enabled or disabled. ErrorCode.TuningforkNotInitialized if plugin is not initialized.

EnableUploadCallback

ErrorCode EnableUploadCallback()

Enable upload callback.

Off by default. Should be called after library is initialized.

Details
Returns
ErrorCode.Ok if the upload callback could be enabled.

FindFidelityParametersInApk

Result< TFidelity > FindFidelityParametersInApk(
  string filename
)

Load fidelity parameters from the APK "assets/tuningfork/" folder.

Details
Parameters
filename
name of the file
Returns
The fidelity parameters, if successfully loaded.

Flush

ErrorCode Flush()

Force upload of the current histograms.

Details
Returns
ErrorCode.Ok if the upload could be initiated.
ErrorCode.PreviousUploadPending if there is a previous upload blocking this one.
ErrorCode.UploadTooFrequent if less than a minute has elapsed since the previous upload.

FrameTick

ErrorCode FrameTick(
  InstrumentationKeys key
)

Record a frame tick that will be associated with the instrumentation key and the current annotation.

For both advanced and default mode FrameTick is called automatically.

Details
Parameters
key
An instrument key.
Returns
ErrorCode.InvalidInstrumentKey if the instrument key is invalid. ErrorCode.Ok on success.

GetFidelityParameters

Result< TFidelity > GetFidelityParameters(
  TFidelity defaultFidelity,
  uint initialTimeoutMs
)

A blocking call to get fidelity parameters from the server.

You do not need to call this if you pass in a fidelity_params_callback as part of the settings to TuningFork_init. Note that once fidelity parameters are downloaded, any timing information is recorded as being associated with those parameters. If you subsequently call GetFidelityParameters and a new set of parameters is downloaded, any data that is already collected will be submitted to the backend. The parameter request is sent to: url_base + 'applications/' + package_name + '/apks/' + version_number + ':generateTuningParameters'

Details
Parameters
defaultFidelity
these will be assumed current if no parameters could be downloaded
initialTimeoutMs
time to wait before returning from this call when no connection can be made
Returns
ErrorCode.Timeout if there was a timeout before params could be downloaded. ErrorCode.Ok on success.

SetCurrentAnnotation

ErrorCode SetCurrentAnnotation(
  TAnnotation annotation
)

Set the current annotation.

Use only for custom annotation.

Details
Parameters
annotation
current annotation.
Returns
ErrorCode.TuningforkNotInitialized if plugin is not initialized. ErrorCode.InvalidMode if using with default annotation mode. ErrorCode.InvalidAnnotation if annotation is inconsistent with the settings or has invalid value set. ErrorCode.Ok on success.

SetFidelityParameters

ErrorCode SetFidelityParameters(
  TFidelity fidelityParams
)

Set the currently active fidelity parameters.

This function overrides any parameters that have been downloaded if in experiment mode. Use this when, for instance, the player has manually changed the game quality settings. This flushes (i.e. uploads) any data associated with any previous parameters.

Details
Parameters
fidelityParams
The new fidelity parameters
Returns
ErrorCode.Ok if the parameters could be set. ErrorCode.InvalidFidelity if the message has invalid values. ErrorCode.TuningforkNotInitialized if plugin is not initialized. ErrorCode.InvalidMode if using with default fidelity mode.

SetLoadingState

ErrorCode SetLoadingState(
  MessageUtil.LoadingState state
)

Set loading state.

Use only for default annotation. Set MessageUtil.LoadingState.Loading when loading is started.
Important:

  • Don't forget to set MessageUtil.LoadingState.NotLoading when loading is finished.
  • Frame information will not be recorded during loading.

Details
Parameters
state
loading state
Returns
ErrorCode.TuningforkNotInitialized if plugin is not initialized. ErrorCode.InvalidMode if using with custom annotation mode. ErrorCode.Ok on success.

SetMetricLimits

void SetMetricLimits(
  MetricLimits metricLimits
)

Set metric limits.

Call before Start() method.

Details
Parameters
metricLimits

Start

ErrorCode Start()

Start AndroidPerformanceTuner.

Details
Returns
Code returned by Android Performance Tuner library.

StartLoadingGroup

Result< ulong > StartLoadingGroup(
  LoadingTimeMetadata eventMetadata,
  TAnnotation annotation
)

Start a loading group.

Subsequent loading times will be tagged with this group's id until StartLoadingGroup is called again or StopLoadingGroup is called. Note that if you do not intend to call StopLoadingGroup , you should set the metadata and annotation to null.

Details
Parameters
eventMetadata
A LoadingTimeMetadata structure.
annotation
The annotation to use with this event.
Returns
Result and a handle for this event (currently is always null since there can only be one loading group active).

StartRecordingLoadingTime

Result< ulong > StartRecordingLoadingTime(
  LoadingTimeMetadata eventMetadata,
  TAnnotation annotation
)

Record the start of a loading event.

Details
Parameters
eventMetadata
A LoadingTimeMetadata structure.
annotation
The annotation to use with this event.
Returns
ErrorCode.Ok and a handle for this event if recording is successful.

Stop

ErrorCode Stop()

Stop Android Performance Tuner.

Details
Returns
Code returned by Android Performance Tuner library.

StopLoadingGroup

ErrorCode StopLoadingGroup(
  ulong handle
)

Stop recording events as belonging to a group and record a group event.

Details
Parameters
handle
A handle generated by StartLoadingGroup (currently should be 0).
Returns

StopRecordingLoadingTime

ErrorCode StopRecordingLoadingTime(
  ulong handle
)

Record the end of a loading event.

Details
Parameters
handle
A handle generated by StartRecordingLoadingTime
Returns

SwappyIsEnabled

bool SwappyIsEnabled()

Return if swappy is enabled or not.

To enable swappy in Editor go to: Project Settings -> Player -> Resolution and Presentation and activate Optimized Frame Pacing. It is recommended to turn on swappy to archive better frame rate.

Details
Returns
True is swappy is enabled