UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 925 B
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{AllocationTracer as t}from"./AllocationTracer.js";import{ResourceType as r}from"./enums.js";const e={RECORD_ALLOCATIONS:!1};class n{constructor(){for(this._current=new Array,this._allocations=e.RECORD_ALLOCATIONS?new t("WebGLObject"):null;this._current.length<r.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,e,n)=>t+(n<r.UNCOUNTED?e:0)),0)}get resourceInformation(){let t="";if(this.total>0){t+="Live objects:\n";for(let e=0;e<r.COUNT;++e){const n=this._current[e];n>0&&(t+=`${r[e]}: ${n}\n`)}}return t+=this._allocations?.resetLog(),t}}export{n as InstanceCounter,e as test};