private void Capture(ScriptRuntime runtime)
        {
            var snapshot = GetSnapshot(runtime.id);

            snapshot.alive = true;
            unsafe
            {
                fixed(Native.JSMemoryUsage *ptr = &snapshot.memoryUsage)
                {
                    Native.JSApi.JS_ComputeMemoryUsage(runtime, ptr);
                }
            }

            var typeDB = runtime.GetTypeDB();

            snapshot.exportedTypes = typeDB.Count;

            var objectCache = runtime.GetObjectCache();

            snapshot.managedObjectCount = objectCache.GetManagedObjectCount();
            snapshot.jSObjectCount      = objectCache.GetJSObjectCount();
            snapshot.delegateCount      = objectCache.GetDelegateCount();
            snapshot.scriptValueCount   = objectCache.GetScriptValueCount();
            snapshot.scriptPromiseCount = objectCache.GetScriptPromiseCount();

            var timeManager = runtime.GetTimerManager();

            snapshot.activeTimer = timeManager.GetActiveTimeHandleCount();
        }
        private void InspectRuntime(ScriptRuntime runtime)
        {
            if (!_touch)
            {
                Capture(runtime);
            }

            if (GUILayout.Button("Capture"))
            {
                Capture(runtime);
            }

            _sv = EditorGUILayout.BeginScrollView(_sv);
            Block("JSMemoryUsage", () =>
            {
                EditorGUILayout.TextField("malloc_size", ToSizeText(_memoryUsage.malloc_size));
                EditorGUILayout.TextField("malloc_limit", ToCountText(_memoryUsage.malloc_limit));
                EditorGUILayout.TextField("memory_used_size", ToSizeText(_memoryUsage.memory_used_size));
                EditorGUILayout.TextField("malloc_count", ToCountText(_memoryUsage.malloc_count));
                EditorGUILayout.TextField("memory_used_count", ToCountText(_memoryUsage.memory_used_count));
                EditorGUILayout.TextField("atom_count", ToCountText(_memoryUsage.atom_count));
                EditorGUILayout.TextField("atom_size", ToSizeText(_memoryUsage.atom_size));
                EditorGUILayout.TextField("str_count", ToCountText(_memoryUsage.str_count));
                EditorGUILayout.TextField("str_size", ToSizeText(_memoryUsage.str_size));
                EditorGUILayout.TextField("obj_count", ToCountText(_memoryUsage.obj_count));
                EditorGUILayout.TextField("obj_size", ToSizeText(_memoryUsage.obj_size));
                EditorGUILayout.TextField("prop_count", ToCountText(_memoryUsage.prop_count));
                EditorGUILayout.TextField("prop_size", ToSizeText(_memoryUsage.prop_size));
                EditorGUILayout.TextField("shape_count", ToCountText(_memoryUsage.shape_count));
                EditorGUILayout.TextField("shape_size", ToSizeText(_memoryUsage.shape_size));
                EditorGUILayout.TextField("js_func_count", ToCountText(_memoryUsage.js_func_count));
                EditorGUILayout.TextField("js_func_size", ToSizeText(_memoryUsage.js_func_size));
                EditorGUILayout.TextField("js_func_code_size", ToSizeText(_memoryUsage.js_func_code_size));
                EditorGUILayout.TextField("js_func_pc2line_count", ToCountText(_memoryUsage.js_func_pc2line_count));
                EditorGUILayout.TextField("js_func_pc2line_size", ToSizeText(_memoryUsage.js_func_pc2line_size));
                EditorGUILayout.TextField("c_func_count", ToCountText(_memoryUsage.c_func_count));
                EditorGUILayout.TextField("array_count", ToCountText(_memoryUsage.array_count));
                EditorGUILayout.TextField("fast_array_count", ToCountText(_memoryUsage.fast_array_count));
                EditorGUILayout.TextField("fast_array_elements", ToCountText(_memoryUsage.fast_array_elements));
                EditorGUILayout.TextField("binary_object_count", ToCountText(_memoryUsage.binary_object_count));
                EditorGUILayout.TextField("binary_object_size", ToSizeText(_memoryUsage.binary_object_size));
            });

            Block("Misc.", () =>
            {
                var typeDB = runtime.GetTypeDB();
                EditorGUILayout.IntField("Exported Types", typeDB.Count);

                var objectCache = runtime.GetObjectCache();
                EditorGUILayout.IntField("ManagedObject Count", objectCache.GetManagedObjectCount());
                EditorGUILayout.IntField("JSObject Count", objectCache.GetJSObjectCount());
                EditorGUILayout.IntField("Delegate Count", objectCache.GetDelegateCount());

                var timeManager = runtime.GetTimerManager();
                EditorGUILayout.IntField("Active Timer", timeManager.GetActiveTimeHandleCount());
            });

            EditorGUILayout.EndScrollView();
        }
Exemplo n.º 3
0
        private static void OnSnapshotRequest(ScriptRuntime rt, Utils.JSAction act)
        {
            var snapshot = (Snapshot)act.args;

            lock (snapshot)
            {
                unsafe
                {
                    fixed(Native.JSMemoryUsage *ptr = &snapshot.memoryUsage)
                    {
                        Native.JSApi.JS_ComputeMemoryUsage(rt, ptr);
                    }
                }

                var typeDB = rt.GetTypeDB();
                snapshot.exportedTypes = typeDB.Count;

                var objectCache = rt.GetObjectCache();
                snapshot.managedObjectCount = objectCache.GetManagedObjectCount();
                snapshot.jSObjectCount      = objectCache.GetJSObjectCount();
                snapshot.delegateCount      = objectCache.GetDelegateCount();
                snapshot.scriptValueCount   = objectCache.GetScriptValueCount();
                snapshot.scriptPromiseCount = objectCache.GetScriptPromiseCount();

                var timeManager = rt.GetTimerManager();
                snapshot.activeTimers.Clear();
                snapshot.timeNow = timeManager.now;
                timeManager.ForEach((id, delay, deadline, once) => snapshot.activeTimers.Add(new Snapshot.TimerInfo()
                {
                    id       = id,
                    delay    = delay,
                    deadline = deadline,
                    once     = once,
                }));
            }
        }