< Summary

Class:Kongregate.WebGLMemoryStats
Assembly:PluginScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Plugins/WebGLMemoryStats/WebGLMemoryStats.cs
Covered lines:0
Uncovered lines:7
Coverable lines:7
Total lines:48
Line coverage:0% (0 of 7)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
WebGLMemoryStats()0%2100%
GetUsedMemorySize()0%2100%
GetFreeMemorySize()0%2100%
GetTotalMemorySize()0%2100%
GetTotalStackSize()0%2100%
GetStaticMemorySize()0%2100%
GetDynamicMemorySize()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Plugins/WebGLMemoryStats/WebGLMemoryStats.cs

#LineLine coverage
 1using UnityEngine;
 2using System.Runtime.InteropServices;
 3
 4namespace Kongregate {
 5    public class WebGLMemoryStats : MonoBehaviour {
 6        [Tooltip("Interval (in seconds) between log entries")]
 07        public uint LogIntervalSeconds = 15;
 8
 9        public static uint GetUsedMemorySize() {
 010            return GetTotalStackSize() + GetStaticMemorySize() + GetDynamicMemorySize();
 11        }
 12
 13#if UNITY_WEBGL && !UNITY_EDITOR
 14        public static uint GetFreeMemorySize() {
 15            return GetTotalMemorySize() - GetUsedMemorySize();
 16        }
 17
 18        void Start() {
 19            InvokeRepeating("Log", 0, LogIntervalSeconds);
 20        }
 21
 22        private void Log() {
 23            var total = GetTotalMemorySize() / 1024 / 1024;
 24            var used = GetUsedMemorySize() / 1024 / 1024;
 25            var free = GetFreeMemorySize() / 1024 / 1024;
 26            Debug.Log(string.Format("WebGL Memory - Total: {0}MB, Used: {1}MB, Free: {2}MB", total, used, free));
 27        }
 28
 29        [DllImport("__Internal")]
 30        public static extern uint GetTotalMemorySize();
 31
 32        [DllImport("__Internal")]
 33        public static extern uint GetTotalStackSize();
 34
 35        [DllImport("__Internal")]
 36        public static extern uint GetStaticMemorySize();
 37
 38        [DllImport("__Internal")]
 39        public static extern uint GetDynamicMemorySize();
 40#else
 041        public static uint GetFreeMemorySize() { return 0; }
 042        public static uint GetTotalMemorySize() { return 0; }
 043        public static uint GetTotalStackSize() { return 0; }
 044        public static uint GetStaticMemorySize() { return 0; }
 045        public static uint GetDynamicMemorySize() { return 0; }
 46#endif
 47    }
 48}