public IEnumerator Memory([ValueSource(nameof(GetMemoryTests))] MemoryTestDescription testDescription)
    {
        yield return(LoadScene(testDescription.sceneData.scene, testDescription.assetData.asset));

        var unloadTask = Resources.UnloadUnusedAssets();

        while (!unloadTask.isDone)
        {
            yield return(new WaitForEndOfFrame());
        }

        // We run memory tests with 3 different resolutions for texture asset types:
        if (testDescription.assetType.IsSubclassOf(typeof(Texture)))
        {
            foreach (var resolution in memoryTestResolutions)
            {
                var sceneSettings = SetupTestScene(resolution);

                yield return(ReportMemoryUsage(sceneSettings, testDescription));
            }
        }
        else
        {
            var sceneSettings = SetupTestScene();
            yield return(ReportMemoryUsage(sceneSettings, testDescription));
        }
    }
Exemple #2
0
    protected IEnumerator ReportMemoryUsage(MemoryTestDescription testDescription)
    {
        yield return(LoadScene(testDescription.sceneData.scene, testDescription.assetData.asset));

        var sceneSettings = SetupTestScene();

        long totalMemory = 0;
        var  data        = Resources.FindObjectsOfTypeAll(testDescription.assetType);
        var  results     = new List <(string name, long size)>();

        // Measure memory
        foreach (var item in data)
        {
            string name     = String.IsNullOrEmpty(item.name) ? item.GetType().Name : item.name;
            long   currSize = Profiler.GetRuntimeMemorySizeLong(item);

            // There are too many items here so we only keep the one that have a minimun of weight
            if (currSize > sceneSettings.minObjectSize)
            {
                results.Add((name, currSize));
            }

            totalMemory += currSize;
        }

        results.Sort((a, b) => b.size.CompareTo(a.size));

        // Report data
        foreach (var result in results)
        {
            Measure.Custom(new SampleGroup(FormatSampleGroupName(k_Memory, result.name), SampleUnit.Byte, false), result.size);
        }
        Measure.Custom(new SampleGroup(FormatSampleGroupName(k_TotalMemory, testDescription.assetType.Name), SampleUnit.Byte, false), totalMemory);
    }
    public IEnumerator Memory([ValueSource(nameof(GetMemoryTests))] MemoryTestDescription testDescription)
    {
        yield return(LoadScene(testDescription.sceneData.scene, testDescription.assetData.asset));

        var unloadTask = Resources.UnloadUnusedAssets();

        while (!unloadTask.isDone)
        {
            yield return(new WaitForEndOfFrame());
        }

        var sceneSettings = SetupTestScene();

        yield return(ReportMemoryUsage(sceneSettings, testDescription));
    }
 public IEnumerator Memory([ValueSource(nameof(GetMemoryTests))] MemoryTestDescription testDescription)
 {
     yield return(ReportMemoryUsage(testDescription));
 }