< Summary

Class:GLTFBenchmark
Assembly:Assembly-CSharp
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/UnityGLTF/Tests/GLTFBenchmark.cs
Covered lines:0
Uncovered lines:26
Coverable lines:26
Total lines:57
Line coverage:0% (0 of 26)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GLTFBenchmark()0%2100%
Start()0%12300%
OnPerformanceFinish(...)0%6200%
RunTest()0%6200%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/UnityGLTF/Tests/GLTFBenchmark.cs

#LineLine coverage
 1using DCL.Helpers;
 2using System.Collections;
 3using UnityEngine;
 4using UnityGLTF;
 5
 6public class GLTFBenchmark : MonoBehaviour
 7{
 08    public string url = "/GLB/TrunkSeparatedTextures/Trunk.glb";
 9
 10    int count = 0;
 011    public int sampleCount = 100;
 012    float minTime = float.MaxValue;
 013    float maxTime = float.MinValue;
 14
 15    private IEnumerator Start()
 16    {
 017        GLTFSceneImporter.PROFILING_ENABLED = true;
 018        GLTFSceneImporter.budgetPerFrameInMilliseconds = float.MaxValue;
 019        GLTFSceneImporter.OnPerformanceFinish += OnPerformanceFinish;
 020        yield return new WaitForSeconds(1.0f);
 021        RunTest();
 022    }
 23
 24    private void OnPerformanceFinish(float obj)
 25    {
 026        if (count > 1)
 27        {
 028            minTime = Mathf.Min(obj, minTime);
 029            maxTime = Mathf.Max(obj, maxTime);
 30        }
 031    }
 32
 33    GameObject lastGameObjectCreated;
 34
 35    void RunTest()
 36    {
 037        if (count > sampleCount)
 38        {
 039            Debug.Log($"Url = {url} ... Min time = {minTime * 1000}... Max time = {maxTime * 1000}");
 040            return;
 41        }
 42
 043        count++;
 044        GameObject gameObject = new GameObject("Test");
 045        lastGameObjectCreated = gameObject;
 046        GLTFComponent gltfComponent = gameObject.AddComponent<GLTFComponent>();
 047        gltfComponent.Initialize(DCL.Environment.i.platform.webRequest);
 048        GLTFComponent.Settings tmpSettings = new GLTFComponent.Settings()
 49        {
 50            useVisualFeedback = false,
 51            initialVisibility = true,
 52        };
 53
 054        gltfComponent.OnFinishedLoadingAsset += RunTest;
 055        gltfComponent.LoadAsset(TestAssetsUtils.GetPath() + url, TestAssetsUtils.GetPath() + url, false, tmpSettings);
 056    }
 57}