Performance monitoring in all QA tests

Performance monitoring in all QA tests

What to expect after following this guidance:

  1. You should be able make build for your game that can be distributed to the team.
  2. Performance data will be seamlessly monitored in every test your team executes.
  3. You will receive notifications if the game doesn’t meet the target.

If you have any issues or questions with the integration, please feel free to contact our support team via support@gamebench.net

Add GameBench SDK package to manifest

Packages/manifest.json

Add com.gamebench.sdk to dependencies with file:path/to/sdk.tgz

Generate a JSON configuration file and write it into the project directory
{
  "serverendpoint": "https://<gamebench server base URL>/v1/sessions/import",
  "emailaddress": "<project user>",
  "sdktoken": "<project token>",
  "tags": "foo=bar,baz=bat"
}

You can use tags to add information like branch name, build number, etc. for future data aggregation.

Build script

Add Autobuilder.cs script to project

using System;
using System.IO;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEditor.iOS.Xcode.Extensions;
using System.Text.RegularExpressions;
#if UNITY_2020
using UnityEditor.AddressableAssets;
#else
using UnityEditor.AddressableAssets.Settings;
#endif
using UnityEditor.PackageManager;
using UnityEditor.PackageManager.Requests;

class Autobuilder
{
    static string IOS_TEAM_ID = "{{APPLE_DEVELOPER_TEAM_ID}}";
    static string APP_ID = "com.gamebench.trashdash";
    static string[] SCENES = { "Assets/Scenes/Main.unity" };
    static string APK_DEST_PATH = "/path/for/app.apk";
    static string IOS_OUTPUT_DIR = "/path/for/ios/output";

    private static void processPendingAction(string action)
    {
        bool isAndroid = (action == "buildAndroid");
        string buildPath = isAndroid ? APK_DEST_PATH : IOS_OUTPUT_DIR;

        // Configure the build
        BuildTarget target = isAndroid ? BuildTarget.Android : BuildTarget.iOS;
        BuildTargetGroup group = isAndroid ? BuildTargetGroup.Android : BuildTargetGroup.iOS;
        PlayerSettings.SetApplicationIdentifier(group, APP_ID);
        PlayerSettings.SetScriptingBackend(group, ScriptingImplementation.IL2CPP);
        PlayerSettings.SetApiCompatibilityLevel(group, ApiCompatibilityLevel.NET_Standard_2_0);
        if (isAndroid)
        {
            PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel21;
        }
        else 
        {
            PlayerSettings.iOS.appleEnableAutomaticSigning = true;
            PlayerSettings.iOS.targetDevice = iOSTargetDevice.iPhoneAndiPad;
            PlayerSettings.iOS.appleDeveloperTeamID = IOS_TEAM_ID;
        }

        // Do the build. This can take a while!
        AddressableAssetSettings.BuildPlayerContent();
        BuildPipeline.BuildPlayer(SCENES, buildPath, target, BuildOptions.Development);

        // Exit the editor if in batch mode
        if (Application.isBatchMode)
            EditorApplication.Exit(0);
    }

    private static void StartBuild(string action) 
    {
        processPendingAction(action);
    }

    static void PerformAndroidBuild()
    {
        StartBuild("buildAndroid");
    }

    static void PerformIosBuild()
    {
        StartBuild("buildIOS");
    }

}
#endif
Start the Unity build using the command line

Android

<path to Unity binary> \
    -batchmode \
    -executeMethod PerformAndroidBuild \
    -email <email> \
    -password <password> \
    -projectPath <project path> \
    -buildTarget Android \
    -logfile \
    -

iOS

<path to Unity binary> \
    -batchmode \
    -executeMethod PerformIosBuild \
    -email <email> \
    -password <password> \
    -projectPath <project path> \
    -buildTarget iOS \
    -logfile \
    -

To generate an IPA, you’ll need to run the following additional commands in the iOS output directory:

xcodebuild -scheme Unity-iPhone archive -archivePath /path/to/build.xcarchive

Example plist file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>compileBitcode</key>
        <false/>
        <key>destination</key>
        <string>export</string>
        <key>method</key>
        <string>development</string>
        <key>signingStyle</key>
        <string>automatic</string>
        <key>teamID</key>
        <string>{{your Apple team ID}}</string>
    </dict>
</plist>
xcodebuild -exportArchive -archivePath /path/to/build.xcarchive -exportOptionsPlist ExportOptions.plist -exportPath /path/to/ipa/dir
Last updated on