| | 1 | | using UnityEngine; |
| | 2 | |
|
| | 3 | | namespace DCL |
| | 4 | | { |
| | 5 | | public static class MetricsScoreUtils |
| | 6 | | { |
| | 7 | | public static long ComputeAudioClipScore(AudioClip audioClip) |
| | 8 | | { |
| 22 | 9 | | if (audioClip == null) |
| 0 | 10 | | return 0; |
| | 11 | |
|
| 22 | 12 | | long baseOverhead = 3000; // Measured 2708 profiling AudioClip with 1 sample and 2 channels. |
| | 13 | | // Rounding up just in case. |
| | 14 | |
|
| | 15 | | // For most cases the sample resolution should be of 65535 (PCM) |
| | 16 | | const double BYTES_PER_SAMPLE = 2; |
| 22 | 17 | | return (long) (audioClip.samples * audioClip.channels * BYTES_PER_SAMPLE) + baseOverhead; |
| | 18 | | } |
| | 19 | |
|
| | 20 | | public static long ComputeTextureScore(Texture2D texture) |
| | 21 | | { |
| 252 | 22 | | if (texture == null) |
| 0 | 23 | | return 0; |
| | 24 | |
|
| | 25 | | // The mipmap memory increase should be actually 1.33 according to many sources |
| | 26 | | const double MIPMAP_FACTOR = 1.4f; |
| | 27 | | const double BYTES_PER_PIXEL = 4; |
| 252 | 28 | | return (long) (texture.width * texture.height * BYTES_PER_PIXEL * MIPMAP_FACTOR); |
| | 29 | | } |
| | 30 | | } |
| | 31 | | } |