Merge pull request #501 from laf/scrut-performance

Fixed the performance issues in scrut
This commit is contained in:
Neil Lathwood
2015-02-22 18:16:10 +00:00
3 changed files with 24 additions and 12 deletions

View File

@@ -560,7 +560,8 @@ function collectd_draw_rrd($host, $plugin, $pinst = null, $type, $tinst = null,
$rrd_cmd = array_merge($rrd_cmd, $config['rrd_opts_array'], $opts['rrd_opts'], $graph);
$cmd = RRDTOOL;
for ($i = 1; $i < count($rrd_cmd); $i++)
$count_rrd_cmd = count($rrd_cmd);
for ($i = 1; $i < $count_rrd_cmd; $i++)
$cmd .= ' '.escapeshellarg($rrd_cmd[$i]);
return $cmd;
@@ -611,7 +612,8 @@ function collectd_draw_generic($timespan, $host, $plugin, $pinst = null, $type,
$rrdgraph = array_merge($rrd_cmd, $rrd_args);
$cmd = RRDTOOL;
for ($i = 1; $i < count($rrdgraph); $i++)
$count_rrdgraph = count($rrdgraph);
for ($i = 1; $i < $count_rrdgraph; $i++)
$cmd .= ' '.escapeshellarg($rrdgraph[$i]);
return $cmd;
@@ -712,7 +714,8 @@ function collectd_draw_meta_stack(&$opts, &$sources) {
}
$rrdcmd = RRDTOOL;
for ($i = 1; $i < count($cmd); $i++)
$count_cmd = count($cmd);
for ($i = 1; $i < $count_cmd; $i++)
$rrdcmd .= ' '.escapeshellarg($cmd[$i]);
return $rrdcmd;
}
@@ -793,7 +796,8 @@ function collectd_draw_meta_line(&$opts, &$sources) {
}
$rrdcmd = RRDTOOL;
for ($i = 1; $i < count($cmd); $i++)
$count_cmd = count($cmd);
for ($i = 1; $i < $count_cmd; $i++)
$rrdcmd .= ' '.escapeshellarg($cmd[$i]);
return $rrdcmd;
}

View File

@@ -489,7 +489,8 @@ class Console_Table
$this->_splitMultilineRows();
// Update cell lengths.
for ($i = 0; $i < count($this->_headers); $i++) {
$count_headers = count($this->_headers);
for ($i = 0; $i < $count_headers; $i++) {
$this->_calculateCellLengths($this->_headers[$i]);
}
for ($i = 0; $i < $this->_max_rows; $i++) {
@@ -570,8 +571,10 @@ class Console_Table
$separator = $this->_getSeparator();
$return = array();
for ($i = 0; $i < count($this->_data); $i++) {
for ($j = 0; $j < count($this->_data[$i]); $j++) {
$count_data = count($this->_data);
for ($i = 0; $i < $count_data; $i++) {
$count_data_i = count($this->_data[$i]);
for ($j = 0; $j < $count_data_i; $j++) {
if ($this->_data[$i] !== CONSOLE_TABLE_HORIZONTAL_RULE &&
$this->_strlen($this->_data[$i][$j]) <
$this->_cell_lengths[$j]) {
@@ -648,7 +651,8 @@ class Console_Table
function _getHeaderLine()
{
// Make sure column count is correct
for ($j = 0; $j < count($this->_headers); $j++) {
$count_headers = count($this->_headers);
for ($j = 0; $j < $count_headers; $j++) {
for ($i = 0; $i < $this->_max_cols; $i++) {
if (!isset($this->_headers[$j][$i])) {
$this->_headers[$j][$i] = '';
@@ -656,8 +660,10 @@ class Console_Table
}
}
for ($j = 0; $j < count($this->_headers); $j++) {
for ($i = 0; $i < count($this->_headers[$j]); $i++) {
$count_headers = count($this->_headers);
for ($j = 0; $j < $count_headers; $j++) {
$count_headers_j = count($this->_headers[$j]);
for ($i = 0; $i < $count_headers_j; $i++) {
if ($this->_strlen($this->_headers[$j][$i]) <
$this->_cell_lengths[$i]) {
$this->_headers[$j][$i] =
@@ -733,7 +739,8 @@ class Console_Table
*/
function _calculateCellLengths($row)
{
for ($i = 0; $i < count($row); $i++) {
$count_row = count($row);
for ($i = 0; $i < $count_row; $i++) {
if (!isset($this->_cell_lengths[$i])) {
$this->_cell_lengths[$i] = 0;
}

View File

@@ -313,7 +313,8 @@ function dbMakeQuery($sql, $parameters) {
// every-other item in $result will be the placeholder that was found
$query = '';
for($i = 0; $i < sizeof($result); $i+=2) {
$res_size = sizeof($result);
for($i = 0; $i < $res_size; $i+=2) {
$query .= $result[ $i ];
$j = $i+1;