Skip to content

Commit

Permalink
Merge pull request #431 from magento/MQE-1055
Browse files Browse the repository at this point in the history
MQE-1055: [SPIKE] Audit performance issues with test generation in framework
  • Loading branch information
tomreece authored Aug 27, 2019
2 parents ee12a62 + c9120e0 commit 3c7ed4b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ class ActionGroupObject
*/
private $filename;

/**
* Holds on to the result of extractStepKeys() to increase test generation performance.
*
* @var string[]
*/
private $cachedStepKeys = null;

/**
* ActionGroupObject constructor.
*
Expand Down Expand Up @@ -409,16 +416,18 @@ private function replacePersistedArgument($replacement, $attributeValue, $fullVa
*/
public function extractStepKeys()
{
$originalKeys = [];
foreach ($this->parsedActions as $action) {
//limit actions returned to list that are relevant
foreach (self::STEPKEY_REPLACEMENT_ENABLED_TYPES as $actionValue) {
if ($actionValue === $action->getType()) {
if ($this->cachedStepKeys === null) {
$originalKeys = [];
foreach ($this->parsedActions as $action) {
//limit actions returned to list that are relevant
if (in_array($action->getType(), self::STEPKEY_REPLACEMENT_ENABLED_TYPES)) {
$originalKeys[] = $action->getStepKey();
}
}
$this->cachedStepKeys = $originalKeys;
}
return $originalKeys;

return $this->cachedStepKeys;
}

/**
Expand Down
15 changes: 13 additions & 2 deletions src/Magento/FunctionalTestingFramework/Test/Objects/TestObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ class TestObject
*/
private $parentTest;

/**
* Holds on to the result of getOrderedActions() to increase test generation performance.
*
* @var ActionObject[]
*/
private $cachedOrderedActions = null;

/**
* TestObject constructor.
*
Expand Down Expand Up @@ -255,8 +262,12 @@ public function getCustomData()
*/
public function getOrderedActions()
{
$mergeUtil = new ActionMergeUtil($this->getName(), "Test");
return $mergeUtil->resolveActionSteps($this->parsedSteps);
if ($this->cachedOrderedActions === null) {
$mergeUtil = new ActionMergeUtil($this->getName(), "Test");
$this->cachedOrderedActions = $mergeUtil->resolveActionSteps($this->parsedSteps);
}

return $this->cachedOrderedActions;
}

/**
Expand Down

0 comments on commit 3c7ed4b

Please sign in to comment.