From 72ac150faa41e8fae2b358f37c084e95ae81bba7 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Wed, 21 Dec 2011 08:52:14 +0000 Subject: [PATCH] Synchro: keep track of the memory usage peak (SynchroLog), should the synchro be executed at once or in several steps SVN:trunk[1733] --- core/kpi.class.inc.php | 10 ++++++++++ synchro/synchrodatasource.class.inc.php | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/core/kpi.class.inc.php b/core/kpi.class.inc.php index a9c129941..eed8e380f 100644 --- a/core/kpi.class.inc.php +++ b/core/kpi.class.inc.php @@ -191,6 +191,16 @@ class ExecutionKPI return $output[1] * 1024; } } + + static public function memory_get_peak_usage($bRealUsage = false) + { + if (function_exists('memory_get_peak_usage')) + { + return memory_get_peak_usage($bRealUsage); + } + // PHP > 5.2.1 - this verb depends on a compilation option + return 0; + } } class ApplicationStartupKPI extends ExecutionKPI diff --git a/synchro/synchrodatasource.class.inc.php b/synchro/synchrodatasource.class.inc.php index d44f8b48e..86566203f 100644 --- a/synchro/synchrodatasource.class.inc.php +++ b/synchro/synchrodatasource.class.inc.php @@ -1234,6 +1234,8 @@ class SynchroLog extends DBObject MetaModel::Init_AddAttribute(new AttributeText("last_error", array("allowed_values"=>null, "sql"=>"last_error", "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeLongText("traces", array("allowed_values"=>null, "sql"=>"traces", "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeInteger("memory_usage_peak", array("allowed_values"=>null, "sql"=>"memory_usage_peak", "default_value"=>0, "is_null_allowed"=>false, "depends_on"=>array()))); + // Display lists MetaModel::Init_SetZListItems('details', array('sync_source_id', 'start_date', 'end_date', 'status', 'stats_nb_replica_total', 'stats_nb_replica_seen', 'stats_nb_obj_created', /*'stats_nb_replica_reconciled',*/ 'stats_nb_obj_updated', 'stats_nb_obj_obsoleted', 'stats_nb_obj_deleted', 'stats_nb_obj_created_errors', 'stats_nb_replica_reconciled_errors', 'stats_nb_replica_disappeared_no_action', 'stats_nb_obj_updated_errors', 'stats_nb_obj_obsoleted_errors', 'stats_nb_obj_deleted_errors', 'stats_nb_obj_new_unchanged', 'stats_nb_obj_new_updated', 'traces')); // Attributes to be displayed for the complete details @@ -1338,6 +1340,8 @@ class SynchroLog extends DBObject protected function OnUpdate() { $this->TraceToText(); + $sMemPeak = max($this->Get('memory_usage_peak'), ExecutionKPI::memory_get_peak_usage()); + $this->Set('memory_usage_peak', $sMemPeak); parent::OnUpdate(); } }