C API Reference

The SDK’s C API is declared in GameBench.h and is implemented by GameBench.aar on Android and GameBench.framework on iOS. These files are found in the GameBench SDK .zip. Please see the Integration Guide for adding these files to your project.

The C API is contained by the IGameBench interface (i.e. a struct containing function pointers), which is obtainable through the global helper function getGameBench(). The APIs that follow are all members of this interface.

⚠️
These APIs will soon be changing to match the C# API.

Sessions

int sessionStart(const char* title)
Starts a new capture session, with an optional title.

int sessionStop()
Stops the current capture session.

int upload(GameBenchUploadCallback callback, void* callbackToken)
Uploads any outstanding sessions to the endpoint configured in the UI. After successful upload the session data will be removed from the device. Must be called without an active session.

NB: The callback is a nullable pointer to a function with the signature void (*)(void*, int, const char*). The first parameter corresponds to whatever you passed as the callbackToken parameter.

Metric capture

All metrics may be captured at set intervals and/or with the captureNow() method. Metric capture has very low overhead and is asynchronous, it should not affect your app’s observed performance.

int scheduleCapture(int metricType, float freq)
Enable and set the capture interval in seconds for the given metric type (from the MetricType enum in GameBench.h). Can be called with or without an active capture session. Use an interval of 0 or less to disable.

int captureNow(int metricType)
Capture and write out the given metric now.

Note that screenshots are a type of metric (see the SS values in the MetricType enum). To capture a screenshot at 50% the screen resolution you could write captureNow(SS1).

Markers

To isolate specific areas of gameplay such as levels or battles, GameBench provides markers functionality. For example, to isolate performance data during a particular game level, you can call markStart() when the level begins and markStop() when the level is completed.

void markStart(const char* name, const char* group)
Record a ‘start’ marker with the given name and marker group (optional).

void markStop(const char* name, const char* group)
Record a ‘stop’ marker with the given name.

void markLaunchComplete()
Record a ’launch complete’ marker that has special significance in the web dashboard.

Tags

void setTag(const char* name, const char* value)
Set a tag in the tags collection. Passing a value of null will remove it.

Other Configuration

All other configuration values are also settable in code. Note that these values set with these APIs are transient and do not persist beyond process exit.

void setIntConfigItem(const char* name, int value);
void setStringConfigItem(const char* name, const char* value);

The available config items are:

Name Type Notes
url String
email String Email or LDAP username
token String Hex token obtained from your GameBench dashboard
autoSession Int 0=disable, 1=enable
markSceneChanges Int
verboseLog Int
Last updated on