diff options
author | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2009-03-27 08:53:48 +0300 |
---|---|---|
committer | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2009-03-27 08:53:48 +0300 |
commit | bc89b5ec03cf3833a41560110b0e433f93232c22 (patch) | |
tree | 2f43f6a73739276380399ec8ed2b0eb40fdf2fb6 /plugins/Referers/Referers.php | |
parent | cd91ede1a0455b07039df0295a52f94924fdf204 (diff) |
- memory and speed optimizations of archiving, refs #374 (hopefully fixing it but not sure yet)
- added support for profiling memory & time in Piwik via the events mechanism
- small other changes
Diffstat (limited to 'plugins/Referers/Referers.php')
-rw-r--r-- | plugins/Referers/Referers.php | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/plugins/Referers/Referers.php b/plugins/Referers/Referers.php index c1ed78bb0b..b027bdbaff 100644 --- a/plugins/Referers/Referers.php +++ b/plugins/Referers/Referers.php @@ -128,11 +128,25 @@ class Piwik_Referers extends Piwik_Plugin * @var Piwik_ArchiveProcessing_Day */ $this->archiveProcessing = $notification->getNotificationObject(); - $this->archiveDayAggregateVisits($this->archiveProcessing); $this->archiveDayAggregateGoals($this->archiveProcessing); Piwik_PostEvent('Referers.archiveDay', $this); $this->archiveDayRecordInDatabase($this->archiveProcessing); + $this->cleanup(); + } + + protected function cleanup() + { + destroy($this->interestBySearchEngine); + destroy($this->interestByKeyword); + destroy($this->interestBySearchEngineAndKeyword); + destroy($this->interestByKeywordAndSearchEngine); + destroy($this->interestByWebsite); + destroy($this->interestByWebsiteAndUrl); + destroy($this->interestByCampaignAndKeyword); + destroy($this->interestByCampaign); + destroy($this->interestByType); + destroy($this->distinctUrls); } protected function archiveDayAggregateVisits($archiveProcessing) @@ -165,7 +179,6 @@ class Piwik_Referers extends Piwik_Plugin $this->interestByCampaign = $this->interestByType = $this->distinctUrls = array(); - while($row = $query->fetch() ) { if(empty($row['referer_type'])) @@ -296,8 +309,9 @@ class Piwik_Referers extends Piwik_Plugin $archiveProcessing->insertNumericRecord($name, $value); } - $data = $archiveProcessing->getDataTableSerialized($this->interestByType); - $archiveProcessing->insertBlobRecord('Referers_type', $data); + $dataTable = $archiveProcessing->getDataTableSerialized($this->interestByType); + $archiveProcessing->insertBlobRecord('Referers_type', $dataTable); + destroy($dataTable); $blobRecords = array( 'Referers_keywordBySearchEngine' => $archiveProcessing->getDataTableWithSubtablesFromArraysIndexedByLabel($this->interestBySearchEngineAndKeyword, $this->interestBySearchEngine), @@ -305,11 +319,11 @@ class Piwik_Referers extends Piwik_Plugin 'Referers_keywordByCampaign' => $archiveProcessing->getDataTableWithSubtablesFromArraysIndexedByLabel($this->interestByCampaignAndKeyword, $this->interestByCampaign), 'Referers_urlByWebsite' => $archiveProcessing->getDataTableWithSubtablesFromArraysIndexedByLabel($this->interestByWebsiteAndUrl, $this->interestByWebsite), ); - foreach($blobRecords as $recordName => $table ) { - $dataToRecord = $table->getSerialized($this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable, $this->columnToSortByBeforeTruncation); - $archiveProcessing->insertBlobRecord($recordName, $dataToRecord); + $blob = $table->getSerialized($this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable, $this->columnToSortByBeforeTruncation); + $archiveProcessing->insertBlobRecord($recordName, $blob); + destroy($table); } } } |