< Summary

Class:DCL.MetricsScoreUtils
Assembly:MainScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/SceneMetricsCounter/MetricsScoreUtils.cs
Covered lines:3
Uncovered lines:0
Coverable lines:3
Total lines:30
Line coverage:100% (3 of 3)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ComputeAudioClipScore(...)0%110100%
ComputeTextureScore(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/SceneMetricsCounter/MetricsScoreUtils.cs

#LineLine coverage
 1using UnityEngine;
 2
 3namespace DCL
 4{
 5    public static class MetricsScoreUtils
 6    {
 7        public static long ComputeAudioClipScore(AudioClip audioClip)
 8        {
 219            long baseOverhead = 3000; // Measured 2708 profiling AudioClip with 1 sample and 2 channels.
 10            // Rounding up just in case.
 11
 12            // For most cases the sample resolution should be of 65535 (PCM)
 13            // But the size seems to be rounded up to 4 bytes. (Maybe due to Mono aligning the bytes?)
 14            const double BYTES_PER_SAMPLE = 4;
 2115            return (long) (audioClip.samples * audioClip.channels * BYTES_PER_SAMPLE) + baseOverhead;
 16        }
 17
 18        public static long ComputeTextureScore(Texture2D texture)
 19        {
 20            // https://forum.unity.com/threads/does-unity-always-use-double-memory-for-texture-in-runtime.198270/
 21            const double ARBITRARY_UNITY_MEMORY_MULTIPLIER = 2;
 22
 23            // The mipmap memory increase should be actually 1.33 according to many sources
 24            const double MIPMAP_FACTOR = 1.4f;
 25            const double BYTES_PER_PIXEL = 4;
 22126            return (long) (texture.width * texture.height * BYTES_PER_PIXEL * MIPMAP_FACTOR *
 27                           ARBITRARY_UNITY_MEMORY_MULTIPLIER);
 28        }
 29    }
 30}