UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

73 lines (72 loc) 1.57 kB
"use strict"; import { Poly } from "../../../Poly"; const performance = Poly.performance.performanceManager(); export class NodeCookPerformanceformanceController { constructor(cookController) { this.cookController = cookController; this._inputsStart = 0; this._inputsTime = 0; this._paramsStart = 0; this._paramsTime = 0; this._cookStart = 0; this._cookTime = 0; this._cooksCount = 0; this._data = { inputsTime: 0, paramsTime: 0, cookTime: 0 }; } cooksCount() { return this._cooksCount; } data() { this._data.inputsTime = this._inputsTime; this._data.paramsTime = this._paramsTime; this._data.cookTime = this._cookTime; return this._data; } active() { return this.cookController.performanceRecordStarted(); } // // INPUTS // recordInputsStart() { if (this.active()) { this._inputsStart = performance.now(); } } recordInputsEnd() { if (this.active()) { this._inputsTime = performance.now() - this._inputsStart; } } // // PARAMS // recordParamsStart() { if (this.active()) { this._paramsStart = performance.now(); } } recordParamsEnd() { if (this.active()) { this._paramsTime = performance.now() - this._paramsStart; } } // // COOK // recordCookStart() { if (this.active()) { this._cookStart = performance.now(); } } recordCookEnd() { if (this.active()) { this._cookTime = performance.now() - this._cookStart; this._cooksCount += 1; } } }