Skip to content

Commit

Permalink
Support more non-additive statistics. Add composer.json.
Browse files Browse the repository at this point in the history
  • Loading branch information
fgm committed Sep 19, 2017
1 parent 0af0f4a commit f60a5d4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/vendor/
/Config/Memcache.php
18 changes: 13 additions & 5 deletions Library/Data/Analysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
*/
class Library_Data_Analysis
{
const NON_ADDITIVE = [
'libevent',
'pid',
'pointer_size',
'time',
'uptime',
'version',
];

/**
* Merge two arrays of stats from Command_XX::stats()
Expand All @@ -43,10 +51,10 @@ public static function merge($array, $stats)

# Merging Stats
foreach ($stats as $key => $value) {
if (isset($array[$key]) && ($key != 'version') && ($key != 'uptime')) {
$array[$key] += $value;
} else {
if (! isset($array[$key]) || in_array($key, static::NON_ADDITIVE)) {
$array[$key] = $value;
} else {
$array[$key] += $value;
}
}
return $array;
Expand All @@ -71,7 +79,7 @@ public static function diff($array, $stats)

# Diff for each key
foreach ($stats as $key => $value) {
if (isset($array[$key])) {
if (isset($array[$key]) && ! in_array($key, static::NON_ADDITIVE)) {
$stats[$key] = $value - $array[$key];
}
}
Expand Down Expand Up @@ -316,4 +324,4 @@ public static function hitResize($value)
}
return sprintf('%.0f%s', $value, $unit);
}
}
}
13 changes: 13 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "elijaa/phpmemcacheadmin",
"description": "Graphic stand-alone administration for memcached",
"type": "library",
"license": "Apache-2.0",
"authors": [
{
"name": "Cyrille Mahieux",
"email": "[email protected]"
}
],
"require": {}
}

0 comments on commit f60a5d4

Please sign in to comment.