Improved benchmark tools

SVN:trunk[729]
This commit is contained in:
Romain Quetiez
2010-08-31 13:35:16 +00:00
parent 3c7af6d37f
commit 8fe9d25341
3 changed files with 27 additions and 10 deletions

View File

@@ -52,6 +52,8 @@ class ExecutionKPI
echo "====================<br/>\n"; echo "====================<br/>\n";
$fTotalOp = 0; $fTotalOp = 0;
$iTotalOp = 0; $iTotalOp = 0;
$fMinOp = null;
$fMaxOp = 0;
foreach ($aOpStats as $sArguments => $aEvents) foreach ($aOpStats as $sArguments => $aEvents)
{ {
$fTotalInter = 0; $fTotalInter = 0;
@@ -60,12 +62,18 @@ class ExecutionKPI
{ {
$fTotalInter += $fDuration; $fTotalInter += $fDuration;
$iTotalInter++; $iTotalInter++;
$fMinOp = is_null($fMinOp) ? $fDuration : min($fMinOp, $fDuration);
$fMaxOp = max($fMaxOp, $fDuration);
} }
$fTotalOp += $fTotalInter; $fTotalOp += $fTotalInter;
$iTotalOp++; $iTotalOp++;
echo "$sArguments: $iTotalInter (".round($fTotalInter, 3).")<br/>\n"; echo "$sArguments: $iTotalInter (".round($fTotalInter, 3).")<br/>\n";
} }
echo "Total: $iTotalOp (".round($fTotalOp, 3).")<br/>\n"; echo "Total: $iTotalOp (".round($fTotalOp, 3).")<br/>\n";
echo "Min: ".round($fMinOp, 3)."<br/>\n";
echo "Max: ".round($fMaxOp, 3)."<br/>\n";
echo "Avg: ".round($fTotalOp / $iTotalOp, 3)."<br/>\n";
echo "====================<br/>\n"; echo "====================<br/>\n";
} }
} }

View File

@@ -17,7 +17,7 @@
<address>5, rue du Sentier</address> <address>5, rue du Sentier</address>
<postal_code>75002</postal_code> <postal_code>75002</postal_code>
<city>Paris</city> <city>Paris</city>
<country>Franche</country> <country>France</country>
<parent_id>0</parent_id> <parent_id>0</parent_id>
</Location> </Location>
</Set> </Set>

View File

@@ -218,7 +218,9 @@ class BenchmarkDataCreation
} }
elseif ($iCount == 1) elseif ($iCount == 1)
{ {
$aSample = array(array_rand($aData)); // array_rand() for one item returns only the key
$key = array_rand($aData);
$aSample = array($key);
} }
elseif ($iCount <= count($aData)) elseif ($iCount <= count($aData))
{ {
@@ -226,7 +228,7 @@ class BenchmarkDataCreation
} }
else else
{ {
$aSample = array_merge(array_rand($aData, count($aData)), self::my_array_rand($aData, $iCount - count($aData))); $aSample = array_merge(array_keys($aData), self::my_array_rand($aData, $iCount - count($aData)));
} }
return $aSample; return $aSample;
} }
@@ -239,11 +241,11 @@ class BenchmarkDataCreation
$aTargets = self::GetClassIds($sToClass); $aTargets = self::GetClassIds($sToClass);
$aSample = self::my_array_rand($aTargets, $iCount); $aSample = self::my_array_rand($aTargets, $iCount);
for($iLinked = 0 ; $iLinked < $iCount ; $iLinked++) foreach($aSample as $key)
{ {
$aData = array( $aData = array(
$sAttCodeFrom => $iFrom, $sAttCodeFrom => $iFrom,
$sAttCodeTo => $aSample[$iLinked], $sAttCodeTo => $aTargets[$key],
); );
$this->CreateObject($sLinkClass, $aData); $this->CreateObject($sLinkClass, $aData);
} }
@@ -284,7 +286,7 @@ class BenchmarkDataCreation
'location_id' => self::FindId('Location'), 'location_id' => self::FindId('Location'),
'first_name' => 'Jesus', 'first_name' => 'Jesus',
'name' => 'Deus', 'name' => 'Deus',
'email' => '', 'email' => 'guru@combodo.com',
); );
$iPerson = $this->CreateObject('Person', $aData); $iPerson = $this->CreateObject('Person', $aData);
$aData = array( $aData = array(
@@ -312,7 +314,7 @@ class BenchmarkDataCreation
'location_id' => self::FindId('Location'), 'location_id' => self::FindId('Location'),
'first_name' => 'Little ze', 'first_name' => 'Little ze',
'name' => 'Foo', 'name' => 'Foo',
'email' => '', 'email' => 'foo@combodo.com',
); );
$iPerson = $this->CreateObject('Person', $aData); $iPerson = $this->CreateObject('Person', $aData);
$aData = array( $aData = array(
@@ -362,7 +364,7 @@ class BenchmarkDataCreation
'org_id' => $iOrg, 'org_id' => $iOrg,
'location_id' => $iLoc, 'location_id' => $iLoc,
'name' => 'Fluminense', 'name' => 'Fluminense',
'email' => 'fluminense@nowhere.fr', 'email' => 'fluminense@combodo.com',
); );
$iTeam = $this->CreateObject('Team', $aData); $iTeam = $this->CreateObject('Team', $aData);
@@ -398,7 +400,7 @@ class BenchmarkDataCreation
'org_id' => $iOrg, 'org_id' => $iOrg,
'name' => 'My Service', 'name' => 'My Service',
); );
$iOrg = $this->CreateObject('Service', $aData); $iService = $this->CreateObject('Service', $aData);
///////////////////////// /////////////////////////
// //
@@ -406,6 +408,7 @@ class BenchmarkDataCreation
// //
$aData = array( $aData = array(
'name' => 'My subcategory', 'name' => 'My subcategory',
'service_id' => $iService,
); );
$iOrg = $this->CreateObject('ServiceSubcategory', $aData); $iOrg = $this->CreateObject('ServiceSubcategory', $aData);
@@ -617,6 +620,7 @@ class BenchmarkDataCreation
'service_id' => $this->RandomId('Service'), 'service_id' => $this->RandomId('Service'),
'servicesubcategory_id' => $this->RandomId('ServiceSubcategory'), 'servicesubcategory_id' => $this->RandomId('ServiceSubcategory'),
'title' => 'Incident #'.$i, 'title' => 'Incident #'.$i,
'description' => 'O que aconteceu?',
'ticket_log' => 'Testing...', 'ticket_log' => 'Testing...',
); );
$iTicket = $this->CreateObject('Incident', $aData); $iTicket = $this->CreateObject('Incident', $aData);
@@ -642,6 +646,7 @@ class BenchmarkDataCreation
'service_id' => $this->RandomId('Service'), 'service_id' => $this->RandomId('Service'),
'servicesubcategory_id' => $this->RandomId('ServiceSubcategory'), 'servicesubcategory_id' => $this->RandomId('ServiceSubcategory'),
'title' => 'Big ticket', 'title' => 'Big ticket',
'description' => 'O que aconteceu?',
'ticket_log' => 'Testing...', 'ticket_log' => 'Testing...',
); );
$iTicket = $this->CreateObject('Incident', $aData); $iTicket = $this->CreateObject('Incident', $aData);
@@ -777,6 +782,9 @@ LoginWebPage::DoLogin(); // Check user rights and prompt if needed
$sOperation = Utils::ReadParam('operation', 'step1'); $sOperation = Utils::ReadParam('operation', 'step1');
$oP = new SetupWebPage('iTop benchmark utility'); $oP = new SetupWebPage('iTop benchmark utility');
ExecutionKPI::EnableDuration();
$oKPI = new ExecutionKPI();
try try
{ {
switch($sOperation) switch($sOperation)
@@ -862,5 +870,6 @@ catch(ZZCoreException $e)
{ {
$oP->error("Error: '".$e->getHtmlDesc()."'"); $oP->error("Error: '".$e->getHtmlDesc()."'");
} }
$oKPI->ComputeAndReport('Total execution');
$oP->output(); $oP->output();
?> ?>