"use strict";var TimeMeasure=function(t){if(!Util.isInitialized(t))var t=!1;this.startTime=null,this.running=!1,(t||0===arguments.length)&&this.start(),this.elapsedFrames=0,this.currentFrameStart=0,this.frameTimes=[],this.runningBenchmark=!1,this.benchmarkTimelimit=6e4,this.benchmarkStart=0,Preferences.Application.MEASURE_FRAME_TIME&&(this.$msPerFrame=$('<div style="position: absolute; top: 10px; left: 50%; color: yellow; background-color: black; font-size: 2.5vh"></div>'),$("body").append(this.$msPerFrame))};TimeMeasure.prototype.start=function(){this.running=!0,this.startTime=Date.now()},TimeMeasure.prototype.getElapsedTime=function(){return this.running?Date.now()-this.startTime:0},TimeMeasure.prototype.startBenchmark=function(){this.benchmarkStart=Date.now()},TimeMeasure.prototype.startFrame=function(){0===this.benchmarkStart&&(this.benchmarkStart=Date.now()),this.currentFrameStart=Date.now()},TimeMeasure.prototype.endFrame=function(){if(this.runningBenchmark){var t=Date.now(),e=t-this.currentFrameStart;if(t-this.benchmarkStart>=this.benchmarkTimelimit&&this.frameTimes.push(e),e=e<10?"0"+e.toFixed(0):e.toFixed(),Util.isInitialized(this.$msPerFrame)&&(this.$msPerFrame.html(e),t-this.benchmarkStart>=this.benchmarkTimelimit)){this.$msPerFrame.html("Benchmark ended.");for(var i=0,r=0;r<this.frameTimes.length;r++)i+=this.frameTimes[r];i/=this.frameTimes.length;var a=1/i*1e3;this.$msPerFrame.html("ms: "+i.toFixed(2)+"\nfps: "+a.toFixed(2)),this.runningBenchmark=!1}}};