model/consoleState.js
function(cpu) {
        if (!isNaN(cpu)) {
            var cpuHistory = this.get('cpu');
            if (!cpuHistory) {
                cpuHistory = [];
                this.set('cpu', cpuHistory);
            }

            cpuHistory.push(cpu);
            while (cpuHistory.length > this._statHistory) {
                cpuHistory.shift();
            }

            var avg = 0;
            cpuHistory.filter(function(f) {
                return f !== null;
            }).forEach(function(f) {
                avg += f;
            });
            avg /= cpuHistory.length;
            this.set({
                avgCpu: Math.round(avg)
            });
        }
    }
function(cpu) {
        if (!isNaN(cpu)) {
            var cpuHistory = this.get('cpu');
            if (!cpuHistory) {
                cpuHistory = [];
                this.set('cpu', cpuHistory);
            }

            cpuHistory.push(cpu);
            while (cpuHistory.length > this._statHistory) {
                cpuHistory.shift();
            }

            var avg = 0;
            cpuHistory.filter(function(f) {
                return f !== null;
            }).forEach(function(f) {
                avg += f;
            });
            avg /= cpuHistory.length;
            this.set({
                avgCpu: Math.round(avg)
            });
        }
    }
function ( cpu ) { if ( ! isNaN ( cpu ) ) { var cpuHistory = this . get ( 'cpu' ) ; if ( ! cpuHistory ) { cpuHistory = [ ] ; this . set ( 'cpu' , cpuHistory ) ; } cpuHistory . push ( cpu ) ; while ( cpuHistory . length > this . _statHistory ) { cpuHistory . shift ( ) ; } var avg = 0 ; cpuHistory . filter ( function ( f ) { return f !== null ; } ) . forEach ( function ( f ) { avg += f ; } ) ; avg /= cpuHistory . length ; this . set ( { avgCpu : Math . round ( avg ) } ) ; } }
Add a CPU sample to the history.
Add a CPU sample to the history .