Stores in memory (static var) all data. Calculates max, min, total

@todo convert int numbers to floats to avoid overflows in totals
190187
public static function insertStats( array $data )
    {
        $vars = array_values( eZPerfLoggerINI::variable( 'GeneralSettings', 'TrackVariables' ) );
        foreach( $data as $datapoint )
        {
            foreach( $datapoint['counters'] as $i => $value )
            {
                $varname = $vars[$i];
                if ( !isset( self::$stats[$varname]['min'] ) || self::$stats[$varname]['min'] > $value )
                {
                    self::$stats[$varname]['min'] = $value;
                }
                if ( !isset( self::$stats[$varname]['max'] ) || self::$stats[$varname]['max'] < $value )
                {
                    self::$stats[$varname]['max'] = $value;
                }
                self::$stats[$varname]['total'] = self::$stats[$varname]['total'] + $value;
            }
        }
        self::$statsCount = self::$statsCount + count( $data );
    }
1257882
private void init()
	{

		sum = BigInteger.ZERO;
		sumByMillisec = BigInteger.ZERO;
		currentVal = -1;
		count =0;
		avg = -1;
		max = -1;
		min = -1;
	}
367409
private void onEnd()
   {
      long result = System.currentTimeMillis() - currentTime.get().poll();
      times.incrementAndGet();
      if (result < min.get())
      {
         min.set(result);
      }
      if (max.get() < result)
      {
         max.set(result);
      }
      total.addAndGet(result);
   }
948617
function(attr) {
			// Get the numbers
			var arr = this.arr;

			// Go through each of the numbers and find the minimum
			var minimum = attr == null ? arr[0] : arr[0][attr];
			var minimumEl = attr == null ? arr[0] : arr[0];

			stats(arr).each(function(num, index) {
				if ((attr == null ? num : num[attr]) < minimum) {
					minimum = attr == null ? num : num[attr];
					minimumEl = num;
				}
			});

			return minimumEl;
		}
120233
def allocate_new_object_number

            last_object = self.each_object(compressed: true).max_by {|object| object.no }
            if last_object.nil?
                no = 1
            else
                no = last_object.no + 1
            end

            [ no, 0 ]
        end
868767
def store_variable(var)
      # Force the correct bounds since we can't explicitly specify binary
      if var.type == :binary
        var.instance_variable_set(:@lower_bound, 0)
        var.instance_variable_set(:@upper_bound, 1)
      end
      set_variable_bounds var.index, var.lower_bound, var.upper_bound, true

      Cbc.Cbc_setObjCoeff @ptr, var.index, var.coefficient
      Cbc.Cbc_setColName(@ptr, var.index, var.name) unless var.name.nil?
      set_variable_type var.index, var.type
    end
17562
public function calculate()
    {
        $this->parameters = $this->leastSquares($this->ys, $this->xs, $this->ws)->getColumn(0);
    }
878113
static int adjustByteCount(final int offset, final int count, final int memorySize) {
    final int available = Math.max(0, memorySize - offset);
    return Math.min(available, count);
  }
627234
protected function _storeData() {
		if ($this->_currentCellIsDirty) {
			$this->_currentObject->detach();

			fseek($this->_fileHandle,0,SEEK_END);
			$offset = ftell($this->_fileHandle);
			fwrite($this->_fileHandle, serialize($this->_currentObject));
			$this->_cellCache[$this->_currentObjectID]	= array('ptr' => $offset,
																'sz'  => ftell($this->_fileHandle) - $offset
															   );
			$this->_currentCellIsDirty = false;
		}
		$this->_currentObjectID = $this->_currentObject = null;
	}
1108360
public function balance () {
			if (!isset($this->cache['balance'])) {
				$tmp = $this->apiCall('get_balance');
				if (!$tmp['data']) return false;

				$this->cache['balance'] = $tmp['data']['value'];
			}

			return (float)$this->cache['balance'];
		}
1305676
def store_variable(var)
      # Update the variable to track the index in the model
      index = @var_count + 1
      var.model = self
      var.index = index
      @var_count += 1

      @variables << var

      # Set variable properties
      GLPK.glp_set_col_name(@ptr, index, var.name)
      GLPK.glp_set_col_kind(@ptr, index, glpk_type(var.type))
      GLPK.glp_set_obj_coef(@ptr, index, var.coefficient)
      set_variable_bounds index, var.lower_bound, var.upper_bound
    end
458603
private function calculateOffset()
    {
        // When no limit is provided, all items are on one page, so the offset is unreasonable
        if (! $this->hasLimit()) {
            $this->setOffset(0);
            return;
        }

        $offset = ($this->getPage() * $this->getLimit()) - $this->getLimit();

        $this->setOffset((int)$offset);
    }
1052834
function onData(W) {
        var buffer = getBuffer(W),
            full = false,
            dropVal,
            N = 0,
            max = Number.NEGATIVE_INFINITY;

        // Initialize max to be < any potential array value.

        /**
        * FUNCTION: onData(newVal, encoding, clbk)
        *   Data event handler. Calculates the moving maximum.
        *
        * @private
        * @param {Number} newVal - streamed data value
        * @param {String} encoding
        * @param {Function} clbk - callback invoked after find the maximum. Function accepts two arguments: [ error, chunk ].
        */
        return function onData(newVal, encoding, clbk) {
            // Fill buffer of size W, find initial max
            if (!full) {
                buffer[N] = newVal;
                if (buffer[N] > max) {
                    max = buffer[N];
                }
                N++;
                if (N===W) {
                    full = true;
                    this.push(max);
                }
                clbk();
                return;
            }

            // Update buffer: (drop old value, add new)
            dropVal = buffer.shift();
            buffer.push(newVal);

            // Find the max...

            // Case 1:
            if (dropVal === max && newVal < max){
                max = buffer[0];
                for(var j=1; j<W; j++){
                    if (buffer[j] > max) {
                        max = buffer[j];
                    }
                }
            }
            // Case 2:
            if (newVal > max){
                max = newVal;
            }
            clbk(null, max);
        }; // end FUNCTION onData()
    }
940048
private void calculate() {
        if (niceScale) {
            this.niceRange = calcNiceNumber(maxValue - minValue, false);
            this.majorTickSpacing = calcNiceNumber(niceRange / (maxNoOfMajorTicks - 1), true);
            this.niceMinValue = Math.floor(minValue / majorTickSpacing) * majorTickSpacing;
            this.niceMaxValue = Math.ceil(maxValue / majorTickSpacing) * majorTickSpacing;
            this.minorTickSpacing = calcNiceNumber(majorTickSpacing / (maxNoOfMinorTicks - 1), true);
            this.range = niceMaxValue - niceMinValue;
        } else {
            this.niceRange = (maxValue - minValue);
            this.niceMinValue = minValue;
            this.niceMaxValue = maxValue;
            this.range = this.niceRange;
        }
    }
586358
protected function getTotal()
	{
		if (null == $this->_total) {
			$this->_total = 0;
			foreach ($this->types as $type) {
				if (isset($type['value'])) {
					$this->_total += $type['value'];
				}
			}
		}
		return $this->_total;
	}
940860
function arrayMax(data) {
	var i = data.length,
		max = data[0];

	while (i--) {
		if (data[i] > max) {
			max = data[i];
		}
	}
	return max;
}
1265625
private function calc()
    {
        $this->limitOffset = max((int)(($this->page - 1) * $this->count), 0);
        $this->limitEndOffset = $this->limitOffset + $this->count;
    }