1 |
- {"ast":null,"code":"import { PrecisionDate } from \"./precisionDate.js\";\n/**\n * This class is used to track a performance counter which is number based.\n * The user has access to many properties which give statistics of different nature.\n *\n * The implementer can track two kinds of Performance Counter: time and count.\n * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.\n * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.\n */\nexport class PerfCounter {\n /**\n * Returns the smallest value ever\n */\n get min() {\n return this._min;\n }\n /**\n * Returns the biggest value ever\n */\n get max() {\n return this._max;\n }\n /**\n * Returns the average value since the performance counter is running\n */\n get average() {\n return this._average;\n }\n /**\n * Returns the average value of the last second the counter was monitored\n */\n get lastSecAverage() {\n return this._lastSecAverage;\n }\n /**\n * Returns the current value\n */\n get current() {\n return this._current;\n }\n /**\n * Gets the accumulated total\n */\n get total() {\n return this._totalAccumulated;\n }\n /**\n * Gets the total value count\n */\n get count() {\n return this._totalValueCount;\n }\n /**\n * Creates a new counter\n */\n constructor() {\n this._startMonitoringTime = 0;\n this._min = 0;\n this._max = 0;\n this._average = 0;\n this._lastSecAverage = 0;\n this._current = 0;\n this._totalValueCount = 0;\n this._totalAccumulated = 0;\n this._lastSecAccumulated = 0;\n this._lastSecTime = 0;\n this._lastSecValueCount = 0;\n }\n /**\n * Call this method to start monitoring a new frame.\n * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.\n */\n fetchNewFrame() {\n this._totalValueCount++;\n this._current = 0;\n this._lastSecValueCount++;\n }\n /**\n * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)\n * @param newCount the count value to add to the monitored count\n * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.\n */\n addCount(newCount, fetchResult) {\n if (!PerfCounter.Enabled) {\n return;\n }\n this._current += newCount;\n if (fetchResult) {\n this._fetchResult();\n }\n }\n /**\n * Start monitoring this performance counter\n */\n beginMonitoring() {\n if (!PerfCounter.Enabled) {\n return;\n }\n this._startMonitoringTime = PrecisionDate.Now;\n }\n /**\n * Compute the time lapsed since the previous beginMonitoring() call.\n * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter\n */\n endMonitoring(newFrame = true) {\n if (!PerfCounter.Enabled) {\n return;\n }\n if (newFrame) {\n this.fetchNewFrame();\n }\n const currentTime = PrecisionDate.Now;\n this._current = currentTime - this._startMonitoringTime;\n if (newFrame) {\n this._fetchResult();\n }\n }\n /**\n * Call this method to end the monitoring of a frame.\n * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the end of the frame, after beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.\n */\n endFrame() {\n this._fetchResult();\n }\n /** @internal */\n _fetchResult() {\n this._totalAccumulated += this._current;\n this._lastSecAccumulated += this._current;\n // Min/Max update\n this._min = Math.min(this._min, this._current);\n this._max = Math.max(this._max, this._current);\n this._average = this._totalAccumulated / this._totalValueCount;\n // Reset last sec?\n const now = PrecisionDate.Now;\n if (now - this._lastSecTime > 1000) {\n this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;\n this._lastSecTime = now;\n this._lastSecAccumulated = 0;\n this._lastSecValueCount = 0;\n }\n }\n}\n/**\n * Gets or sets a global boolean to turn on and off all the counters\n */\nPerfCounter.Enabled = true;","map":{"version":3,"names":["PrecisionDate","PerfCounter","min","_min","max","_max","average","_average","lastSecAverage","_lastSecAverage","current","_current","total","_totalAccumulated","count","_totalValueCount","constructor","_startMonitoringTime","_lastSecAccumulated","_lastSecTime","_lastSecValueCount","fetchNewFrame","addCount","newCount","fetchResult","Enabled","_fetchResult","beginMonitoring","Now","endMonitoring","newFrame","currentTime","endFrame","Math","now"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Misc/perfCounter.js"],"sourcesContent":["import { PrecisionDate } from \"./precisionDate.js\";\n/**\n * This class is used to track a performance counter which is number based.\n * The user has access to many properties which give statistics of different nature.\n *\n * The implementer can track two kinds of Performance Counter: time and count.\n * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.\n * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.\n */\nexport class PerfCounter {\n /**\n * Returns the smallest value ever\n */\n get min() {\n return this._min;\n }\n /**\n * Returns the biggest value ever\n */\n get max() {\n return this._max;\n }\n /**\n * Returns the average value since the performance counter is running\n */\n get average() {\n return this._average;\n }\n /**\n * Returns the average value of the last second the counter was monitored\n */\n get lastSecAverage() {\n return this._lastSecAverage;\n }\n /**\n * Returns the current value\n */\n get current() {\n return this._current;\n }\n /**\n * Gets the accumulated total\n */\n get total() {\n return this._totalAccumulated;\n }\n /**\n * Gets the total value count\n */\n get count() {\n return this._totalValueCount;\n }\n /**\n * Creates a new counter\n */\n constructor() {\n this._startMonitoringTime = 0;\n this._min = 0;\n this._max = 0;\n this._average = 0;\n this._lastSecAverage = 0;\n this._current = 0;\n this._totalValueCount = 0;\n this._totalAccumulated = 0;\n this._lastSecAccumulated = 0;\n this._lastSecTime = 0;\n this._lastSecValueCount = 0;\n }\n /**\n * Call this method to start monitoring a new frame.\n * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.\n */\n fetchNewFrame() {\n this._totalValueCount++;\n this._current = 0;\n this._lastSecValueCount++;\n }\n /**\n * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)\n * @param newCount the count value to add to the monitored count\n * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.\n */\n addCount(newCount, fetchResult) {\n if (!PerfCounter.Enabled) {\n return;\n }\n this._current += newCount;\n if (fetchResult) {\n this._fetchResult();\n }\n }\n /**\n * Start monitoring this performance counter\n */\n beginMonitoring() {\n if (!PerfCounter.Enabled) {\n return;\n }\n this._startMonitoringTime = PrecisionDate.Now;\n }\n /**\n * Compute the time lapsed since the previous beginMonitoring() call.\n * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter\n */\n endMonitoring(newFrame = true) {\n if (!PerfCounter.Enabled) {\n return;\n }\n if (newFrame) {\n this.fetchNewFrame();\n }\n const currentTime = PrecisionDate.Now;\n this._current = currentTime - this._startMonitoringTime;\n if (newFrame) {\n this._fetchResult();\n }\n }\n /**\n * Call this method to end the monitoring of a frame.\n * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the end of the frame, after beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.\n */\n endFrame() {\n this._fetchResult();\n }\n /** @internal */\n _fetchResult() {\n this._totalAccumulated += this._current;\n this._lastSecAccumulated += this._current;\n // Min/Max update\n this._min = Math.min(this._min, this._current);\n this._max = Math.max(this._max, this._current);\n this._average = this._totalAccumulated / this._totalValueCount;\n // Reset last sec?\n const now = PrecisionDate.Now;\n if (now - this._lastSecTime > 1000) {\n this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;\n this._lastSecTime = now;\n this._lastSecAccumulated = 0;\n this._lastSecValueCount = 0;\n }\n }\n}\n/**\n * Gets or sets a global boolean to turn on and off all the counters\n */\nPerfCounter.Enabled = true;\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,oBAAoB;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,WAAW,CAAC;EACrB;AACJ;AACA;EACI,IAAIC,GAAGA,CAAA,E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