Browse Source

Dev: improved performance measure tooling

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1144 a333f486-631f-4898-b8df-5754b55c2be0
romainq 14 years ago
parent
commit
f1ff85a59b
4 changed files with 35 additions and 21 deletions
  1. 8 0
      approot.inc.php
  2. 9 0
      core/kpi.class.inc.php
  3. 3 0
      pages/UI.php
  4. 15 21
      test/benchmark.php

+ 8 - 0
approot.inc.php

@@ -1,3 +1,11 @@
 <?php
 define('APPROOT', dirname(__FILE__).'/');
+if (function_exists('microtime'))
+{
+	$fItopStarted = microtime(true); 
+}
+else
+{
+	$fItopStarted = 1000 * time();
+}
 ?>

+ 9 - 0
core/kpi.class.inc.php

@@ -193,4 +193,13 @@ class ExecutionKPI
 	}
 }
 
+class ApplicationStartupKPI extends ExecutionKPI
+{
+	public function __construct()
+	{
+		global $fItopStarted;
+		$this->m_fStarted	= $fItopStarted;
+	}
+} 
+
 ?>

+ 3 - 0
pages/UI.php

@@ -456,6 +456,9 @@ try
 	require_once(APPROOT.'/application/startup.inc.php');
 	$operation = utils::ReadParam('operation', '');
 
+	$oKPI = new ApplicationStartupKPI();
+	$oKPI->ComputeAndReport('Load of data model and all includes');
+
 	$oKPI = new ExecutionKPI();
 
 	require_once(APPROOT.'/application/loginwebpage.class.inc.php');

+ 15 - 21
test/benchmark.php

@@ -143,6 +143,13 @@ class BenchmarkDataCreation
 		$oMyObject = MetaModel::NewObject($sClass);
 		foreach($aData as $sProp => $value)
 		{
+			if (is_array($value))
+			{
+				// transform into a link set
+				$sCSVSpec = implode('|', $value);
+				$oAttDef = MetaModel::GetAttributeDef($sClass, $sProp);
+				$value = $oAttDef->MakeValueFromString($sCSVSpec, $sSepItem = '|', $sSepAttribute = ';', $sSepValue = ':', $sAttributeQualifier = '"');
+			}
 			$oMyObject->Set($sProp, $value);
 		}
 
@@ -295,18 +302,10 @@ class BenchmarkDataCreation
 			'login' => 'guru',
 			'password' => 'guru',
 			'language' => 'EN US',
+			'profile_list' => array("profileid:$iGuruProfile;reason:he is the one"),
 		);
 		$iLogin = $this->CreateObject('UserLocal', $aData);
 
-		// Assign the guru profile to the new login
-		//
-		$aData = array(
-			'userid' => $iLogin,
-			'profileid' => $iGuruProfile,
-			'reason' => 'he is the one',
-		);
-		$this->CreateObject('URP_UserProfile', $aData);
-
 		////////////////////////////////////////
 		// User login having all std profiles
 		//
@@ -318,26 +317,21 @@ class BenchmarkDataCreation
 			'email' => 'foo@combodo.com',
 		);
 		$iPerson = $this->CreateObject('Person', $aData);
+
+		$aProfileSet = array();
+		foreach($aStdProfiles as $iProfileId)
+		{
+			$aProfileSet[] = "profileid:$iProfileId;reason:xxx";
+		}
 		$aData = array(
 			'contactid' => $iPerson,
 			'login' => 'foo',
 			'password' => 'foo',
 			'language' => 'EN US',
+			'profile_list' => $aProfileSet,
 		);
 		$iLogin = $this->CreateObject('UserLocal', $aData);
 
-		// Assign profiles to the new login
-		//
-		foreach($aStdProfiles as $iProfileId)
-		{
-			$aData = array(
-				'userid' => $iLogin,
-				'profileid' => $iProfileId,
-				'reason' => '',
-			);
-			$this->CreateObject('URP_UserProfile', $aData);
-		}
-
 		/////////////////////////
 		//
 		// Organizations