Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthieu_ <matthieu_@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2007-08-21 21:29:23 +0400
committermatthieu_ <matthieu_@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2007-08-21 21:29:23 +0400
commit7765dfe0c8e71eabaa079b3d94eaf800bda88390 (patch)
treee3bdb872ecfee78c4f2fad38a1385e5903806789 /modules
parentf9275a2a990f29418605e7ee4f3e4b27e9d40a82 (diff)
memory profiling, small enhancements, api specifications
Diffstat (limited to 'modules')
-rw-r--r--modules/Archive.php51
-rw-r--r--modules/ArchiveProcessing.php7
-rw-r--r--modules/ArchiveProcessing/Period.php18
-rw-r--r--modules/ArchiveProcessing/Record.php6
-rw-r--r--modules/DataTable/Manager.php6
-rw-r--r--modules/LogStats/Generator.php10
-rwxr-xr-xmodules/Piwik.php14
-rw-r--r--modules/Plugin.php3
8 files changed, 62 insertions, 53 deletions
diff --git a/modules/Archive.php b/modules/Archive.php
index 522b33e464..d1a52fb558 100644
--- a/modules/Archive.php
+++ b/modules/Archive.php
@@ -101,11 +101,20 @@ class Piwik_Archive
public function get( $name, $typeValue = 'numeric' )
{
- if($this->cacheEnabledForNumeric
+ // values previously "get" and now cached
+ if($typeValue == 'numeric'
+ && $this->cacheEnabledForNumeric
&& isset($this->numericCached[$name])
)
{
- return $this->numericCached[$name][$typeValue];
+ return $this->numericCached[$name];
+ }
+
+ // Values prefetched
+ if($typeValue == 'blob'
+ && isset($this->blobCached[$name]))
+ {
+ return $this->blobCached[$name];
}
$this->prepareArchive();
@@ -126,16 +135,12 @@ class Piwik_Archive
switch($typeValue)
{
case 'blob':
- $tableBlob = $this->archiveProcessing->getTableArchiveBlobName();
- // select data from the blob table
- $table = $tableBlob;
+ $table = $this->archiveProcessing->getTableArchiveBlobName();
break;
case 'numeric':
default:
- $tableNumeric = $this->archiveProcessing->getTableArchiveNumericName();
- // select data from the numeric table (by default)
- $table = $tableNumeric;
+ $table = $this->archiveProcessing->getTableArchiveNumericName();
break;
}
@@ -151,10 +156,11 @@ class Piwik_Archive
// no result, returns false
if($value === false)
{
- if($this->cacheEnabledForNumeric)
+ if($typeValue == 'numeric'
+ && $this->cacheEnabledForNumeric)
{
// we cache the results
- $this->numericCached[$name][$typeValue] = false;
+ $this->numericCached[$name] = false;
}
return $value;
}
@@ -165,17 +171,18 @@ class Piwik_Archive
$value = gzuncompress($value);
}
- if($this->cacheEnabledForNumeric)
+ if($typeValue == 'numeric'
+ && $this->cacheEnabledForNumeric)
{
// we cache the results
- $this->numericCached[$name][$typeValue] = $value;
+ $this->numericCached[$name] = $value;
}
return $value;
}
public function getDataTable( $name, $idSubTable = null )
{
- if($idSubTable !== null)
+ if(!is_null($idSubTable))
{
$name .= "_$idSubTable";
}
@@ -209,14 +216,6 @@ class Piwik_Archive
return $this->get($name, 'blob');
}
- // fetches many fields at once for performance
- public function preFetchNumeric( $aName )
- {
- // TODO implement prefetch
-
-
- }
-
public function freeBlob( $name )
{
@@ -247,14 +246,8 @@ class Piwik_Archive
{
$value = $row['value'];
$name = $row['name'];
-
- $value = gzuncompress($value);
-
- // we cache the results
- if($this->cacheEnabledForNumeric)
- {
- $this->numericCached[$name]['blob'] = $value;
- }
+
+ $this->blobCached[$name] = gzuncompress($value);
}
}
}
diff --git a/modules/ArchiveProcessing.php b/modules/ArchiveProcessing.php
index d600b196ff..fa7d122561 100644
--- a/modules/ArchiveProcessing.php
+++ b/modules/ArchiveProcessing.php
@@ -100,11 +100,15 @@ abstract class Piwik_ArchiveProcessing
$this->idArchive = $this->isArchived();
if(!$this->idArchive)
{
+ Piwik::printMemoryUsage('Before loading subperiods');
$this->archivesSubperiods = $this->loadSubperiodsArchive();
-
+ Piwik::printMemoryUsage('After loading subperiods');
$this->initCompute();
+ Piwik::printMemoryUsage('After init compute');
$this->compute();
+ Piwik::printMemoryUsage('After compute');
$this->postCompute();
+ Piwik::printMemoryUsage('After post compute');
Piwik::log("New archive computed, id = {$this->idArchive}");
}
@@ -166,6 +170,7 @@ abstract class Piwik_ArchiveProcessing
// we delete all tables from the table register
Piwik_ArchiveProcessing_Record_Manager::getInstance()->deleteAll();
+
}
diff --git a/modules/ArchiveProcessing/Period.php b/modules/ArchiveProcessing/Period.php
index ceb15d41d2..f29beb0eb6 100644
--- a/modules/ArchiveProcessing/Period.php
+++ b/modules/ArchiveProcessing/Period.php
@@ -13,12 +13,10 @@ class Piwik_ArchiveProcessing_Period extends Piwik_ArchiveProcessing
$aNames = array($aNames);
}
- // fetch the numeric values and sum them
+ // fetch the numeric values and apply the operation on them
$results = array();
foreach($this->archives as $archive)
{
- $archive->preFetchNumeric($aNames);
-
foreach($aNames as $name)
{
if(!isset($results[$name]))
@@ -39,7 +37,6 @@ class Piwik_ArchiveProcessing_Period extends Piwik_ArchiveProcessing
case 'min':
$results[$name] = min($results[$name], $valueToSum);
break;
-
default:
throw new Exception("Operation not applicable.");
break;
@@ -67,10 +64,12 @@ class Piwik_ArchiveProcessing_Period extends Piwik_ArchiveProcessing
// returns the array of records once summed
return $records;
}
+
public function archiveNumericValuesSum( $aNames )
{
return $this->archiveNumericValuesGeneral($aNames, 'sum');
}
+
public function archiveNumericValuesMax( $aNames )
{
return $this->archiveNumericValuesGeneral($aNames, 'max');
@@ -94,7 +93,7 @@ class Piwik_ArchiveProcessing_Period extends Piwik_ArchiveProcessing
}
private function reloadSubtables($name, $dataTableToLoad, $archive)
- {
+ {
// we have to recursively load all the subtables associated to this table's rows
// and update the subtableID so that it matches the newly instanciated table
foreach($dataTableToLoad->getRows() as $row)
@@ -125,8 +124,8 @@ class Piwik_ArchiveProcessing_Period extends Piwik_ArchiveProcessing
// echo $datatableToSum;
$table->addDataTable($datatableToSum);
+ $archive->freeBlob($name);
}
- $archive->freeBlob($name);
// echo $table;
return $table;
}
@@ -146,7 +145,10 @@ class Piwik_ArchiveProcessing_Period extends Piwik_ArchiveProcessing
);
$this->archiveNumericValuesSum($toSum);
- Piwik_PostEvent('ArchiveProcessing_Period.compute', $this);
+ Piwik_PostEvent('ArchiveProcessing_Period.compute', $this);
+
+ //delete all DataTable instanciated
+ Piwik_DataTable_Manager::getInstance()->deleteAll();
+
}
}
-?>
diff --git a/modules/ArchiveProcessing/Record.php b/modules/ArchiveProcessing/Record.php
index cab2d76c25..aa775025fd 100644
--- a/modules/ArchiveProcessing/Record.php
+++ b/modules/ArchiveProcessing/Record.php
@@ -49,7 +49,10 @@ class Piwik_ArchiveProcessing_Record_Manager
public function deleteAll()
{
- unset($this->records);
+ foreach($this->records as $key => $record)
+ {
+ unset($this->records[$key]);
+ }
$this->records = array();
}
}
@@ -71,7 +74,6 @@ abstract class Piwik_ArchiveProcessing_Record
}
public function __destruct()
{
- Piwik_ArchiveProcessing_Record_Manager::getInstance()->unregister($this);
}
}
diff --git a/modules/DataTable/Manager.php b/modules/DataTable/Manager.php
index 7225beaa49..cc93c61089 100644
--- a/modules/DataTable/Manager.php
+++ b/modules/DataTable/Manager.php
@@ -42,12 +42,10 @@ class Piwik_DataTable_Manager
function deleteAll()
{
- foreach($this->tables as $key => $table)
- {
- unset($this->tables[$key]);
- }
+ Piwik::log("DELETE ALL ".$this->count()." TABLES");
$this->tables = array();
}
+
function count()
{
return count($this->tables);
diff --git a/modules/LogStats/Generator.php b/modules/LogStats/Generator.php
index e2ffb7e175..b5d390e860 100644
--- a/modules/LogStats/Generator.php
+++ b/modules/LogStats/Generator.php
@@ -290,7 +290,7 @@ class Piwik_LogStats_Generator
{
if(rand(0,2)==1)
{
- $this->setCurrentRequest( 'action_name' , $this->getRandomString(3,3));
+ $this->setCurrentRequest( 'action_name' , $this->getRandomString(1,1));
}
}
}
@@ -305,10 +305,10 @@ class Piwik_LogStats_Generator
{
$url = $host;
- $deep = mt_rand(0,2);
+ $deep = mt_rand(0,1);
for($i=0;$i<$deep;$i++)
{
- $name = $this->getRandomString(1,2,'alnum');
+ $name = $this->getRandomString(1,1,'alnum');
$url .= '/'.$name;
}
@@ -321,14 +321,14 @@ class Piwik_LogStats_Generator
$len = mt_rand($minLength, $maxLength);
// Register the lower case alphabet array
- $alpha = array('a', 'b', 'c', 'd', 'e', 'f', 'g');
+ $alpha = array('a', 'd', 'e', 'f', 'g');
// Register the upper case alphabet array
$ALPHA = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
// Register the numeric array
- $num = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '0');
+ $num = array('1', '2', '3', '8', '9', '0');
// Register the strange array
$strange = array('/', '?', '!','"','£','$','%','^','&','*','(',')',' ');
diff --git a/modules/Piwik.php b/modules/Piwik.php
index afeab8b518..45c240ec8e 100755
--- a/modules/Piwik.php
+++ b/modules/Piwik.php
@@ -17,7 +17,7 @@ class Piwik
'year' =>4,
);
- static public function log($message, $priority = Zend_Log::NOTICE)
+ static public function log($message = '', $priority = Zend_Log::NOTICE)
{
Zend_Registry::get('logger_message')->log($message);
Zend_Registry::get('logger_message')->log( "<br>" . PHP_EOL);
@@ -43,12 +43,22 @@ class Piwik
static public function printMemoryUsage( $prefixString = null )
{
- $usage = round(memory_get_usage() / 1024 / 1024, 2);
+ if(function_exists('xdebug_memory_usage'))
+ {
+ $memory = xdebug_memory_usage();
+ }
+ else
+ {
+ $memory = memory_get_usage();
+ }
+
+ $usage = round( $memory / 1024 / 1024, 2);
if(!is_null($prefixString))
{
Piwik::log($prefixString);
}
Piwik::log("Memory usage = $usage Mb");
+ Piwik::log();
}
static public function isNumeric($value)
diff --git a/modules/Plugin.php b/modules/Plugin.php
index f7c1431b3b..caf7527e33 100644
--- a/modules/Plugin.php
+++ b/modules/Plugin.php
@@ -8,9 +8,8 @@ abstract class Piwik_Plugin
{
function __construct()
{
- Piwik::log("start of ".__CLASS__);
- Piwik::printMemoryUsage();
}
+
/**
* Returns the plugin details
*/