12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import{AllocationTracer as t}from"../support/AllocationTracer.js";import{ResourceType as r}from"./enums.js";const e={RECORD_ALLOCATIONS:!1};class s{constructor(){for(this._current=new Array,this._max=new Array,this._allocations=new t(e.RECORD_ALLOCATIONS);this._current.length<r.COUNT;)this._current.push(0),this._max.push(0)}resetMax(){for(this._max.length=0;this._max.length<this._current.length;)this._max.push(0)}increment(t,r){const e=++this._current[t];this._max[t]=Math.max(e,this._max[t]),this._allocations.add(r)}decrement(t,r){--this._current[t],this._allocations.remove(r)}get max(){return this._max}get current(){return this._current}get total(){return this.current.reduce(((t,r)=>t+r),0)}printResourceCount(){if(this.total>0){console.log("Live objects:");for(let t=0;t<r.COUNT;++t){const e=this._current[t];e>0&&console.log(`${r[t]}: ${e}`)}}this._allocations.print()}}export{s as InstanceCounter,e as test};
|