model/consoleState.js
function() {
        var fpsHistory = this.get('fps');

        if (!fpsHistory) {
            fpsHistory = [];
            this.set({
                fps: fpsHistory,
            });
        }

        // Update FPS.
        if (this._tickSum) {
            var fps = 1000 / (this._tickSum / this._maxTicks);
            fps *= 100;
            fps = Math.round(fps);
            fps /= 100;
            fpsHistory.push(fps);
            while (fpsHistory.length > this._statHistory) {
                fpsHistory.shift();
            }

            var avg = 0;
            fpsHistory.filter(function(f) {
                return f !== null;
            }).forEach(function(f) {
                avg += f;
            });
            avg /= fpsHistory.length;
            this.set({
                avgFps: Math.round(avg)
            });
        }

        if ($$persistence.processId()) {
            // Update the uptime.
            var wasRunning = this.get('isRunning');
            if (!wasRunning) {
                this._startupTime = Date.now();
            }
            this.set('uptime', Date.now() - this._startupTime);
            this.set('isRunning', true);
        } else {
            // Not running, so reset everything.
            this.set({
                isRunning: false,
                fps: null,
                memory: null,
                uptime: 0
            });
        }

        clearTimeout(this._updateStatsTimeout);
        this._updateStatsTimeout = setTimeout(_.bind(this._updateStats, this), this._updateStatsRate);
    }
function() {
        var fpsHistory = this.get('fps');

        if (!fpsHistory) {
            fpsHistory = [];
            this.set({
                fps: fpsHistory,
            });
        }

        // Update FPS.
        if (this._tickSum) {
            var fps = 1000 / (this._tickSum / this._maxTicks);
            fps *= 100;
            fps = Math.round(fps);
            fps /= 100;
            fpsHistory.push(fps);
            while (fpsHistory.length > this._statHistory) {
                fpsHistory.shift();
            }

            var avg = 0;
            fpsHistory.filter(function(f) {
                return f !== null;
            }).forEach(function(f) {
                avg += f;
            });
            avg /= fpsHistory.length;
            this.set({
                avgFps: Math.round(avg)
            });
        }

        if ($$persistence.processId()) {
            // Update the uptime.
            var wasRunning = this.get('isRunning');
            if (!wasRunning) {
                this._startupTime = Date.now();
            }
            this.set('uptime', Date.now() - this._startupTime);
            this.set('isRunning', true);
        } else {
            // Not running, so reset everything.
            this.set({
                isRunning: false,
                fps: null,
                memory: null,
                uptime: 0
            });
        }

        clearTimeout(this._updateStatsTimeout);
        this._updateStatsTimeout = setTimeout(_.bind(this._updateStats, this), this._updateStatsRate);
    }
function ( ) { var fpsHistory = this . get ( 'fps' ) ; if ( ! fpsHistory ) { fpsHistory = [ ] ; this . set ( { fps : fpsHistory , } ) ; } // Update FPS. if ( this . _tickSum ) { var fps = 1000 / ( this . _tickSum / this . _maxTicks ) ; fps *= 100 ; fps = Math . round ( fps ) ; fps /= 100 ; fpsHistory . push ( fps ) ; while ( fpsHistory . length > this . _statHistory ) { fpsHistory . shift ( ) ; } var avg = 0 ; fpsHistory . filter ( function ( f ) { return f !== null ; } ) . forEach ( function ( f ) { avg += f ; } ) ; avg /= fpsHistory . length ; this . set ( { avgFps : Math . round ( avg ) } ) ; } if ( $$persistence . processId ( ) ) { // Update the uptime. var wasRunning = this . get ( 'isRunning' ) ; if ( ! wasRunning ) { this . _startupTime = Date . now ( ) ; } this . set ( 'uptime' , Date . now ( ) - this . _startupTime ) ; this . set ( 'isRunning' , true ) ; } else { // Not running, so reset everything. this . set ( { isRunning : false , fps : null , memory : null , uptime : 0 } ) ; } clearTimeout ( this . _updateStatsTimeout ) ; this . _updateStatsTimeout = setTimeout ( _ . bind ( this . _updateStats , this ) , this . _updateStatsRate ) ; }
Update the internal objects which specify the FPS, whether the app is running, memory usage, and uptime.
Update the internal objects which specify the FPS whether the app is running memory usage and uptime .