@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 887 B
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{getKey as t}from"../../core/object.js";import{AllocationTracer as r}from"./AllocationTracer.js";import{ResourceType as e}from"./enums.js";const o={RECORD_ALLOCATIONS:!1};class n{constructor(){for(this._current=new Array,this._allocations=o.RECORD_ALLOCATIONS?new r("WebGLObject"):null;this._current.length<e.COUNT;)this._current.push(0)}increment(t,r,e=1){this._current[t]+=e,this._allocations?.add(r)}decrement(t,r,e=1){this._current[t]-=e,this._allocations?.remove(r)}get current(){return this._current}get total(){return this.current.reduce((t,r,o)=>t+(o<e.UNCOUNTED?r:0),0)}get resourceInformation(){let r="";if(this.total>0){r+="Live objects:\n";for(let o=0;o<e.COUNT;++o){const n=this._current[o];n>0&&(r+=`${t(e,o)}: ${n}\n`)}}return r+=this._allocations?.resetLog(),r}}export{n as InstanceCounter,o as test};