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.
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.
Start()
Start AndroidPerformanceTuner.
Stop()
Stop Android Performance Tuner.
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.

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.

Start

ErrorCode Start()

Start AndroidPerformanceTuner.

Details
Returns
Code returned by Android Performance Tuner library.

Stop

ErrorCode Stop()

Stop Android Performance Tuner.

Details
Returns
Code returned by Android Performance Tuner library.

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