Skip to content

Commit 3c7ed4b

Browse files
authored
Merge pull request #431 from magento/MQE-1055
MQE-1055: [SPIKE] Audit performance issues with test generation in framework
2 parents ee12a62 + c9120e0 commit 3c7ed4b

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php

+15-6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ class ActionGroupObject
8787
*/
8888
private $filename;
8989

90+
/**
91+
* Holds on to the result of extractStepKeys() to increase test generation performance.
92+
*
93+
* @var string[]
94+
*/
95+
private $cachedStepKeys = null;
96+
9097
/**
9198
* ActionGroupObject constructor.
9299
*
@@ -409,16 +416,18 @@ private function replacePersistedArgument($replacement, $attributeValue, $fullVa
409416
*/
410417
public function extractStepKeys()
411418
{
412-
$originalKeys = [];
413-
foreach ($this->parsedActions as $action) {
414-
//limit actions returned to list that are relevant
415-
foreach (self::STEPKEY_REPLACEMENT_ENABLED_TYPES as $actionValue) {
416-
if ($actionValue === $action->getType()) {
419+
if ($this->cachedStepKeys === null) {
420+
$originalKeys = [];
421+
foreach ($this->parsedActions as $action) {
422+
//limit actions returned to list that are relevant
423+
if (in_array($action->getType(), self::STEPKEY_REPLACEMENT_ENABLED_TYPES)) {
417424
$originalKeys[] = $action->getStepKey();
418425
}
419426
}
427+
$this->cachedStepKeys = $originalKeys;
420428
}
421-
return $originalKeys;
429+
430+
return $this->cachedStepKeys;
422431
}
423432

424433
/**

src/Magento/FunctionalTestingFramework/Test/Objects/TestObject.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ class TestObject
7171
*/
7272
private $parentTest;
7373

74+
/**
75+
* Holds on to the result of getOrderedActions() to increase test generation performance.
76+
*
77+
* @var ActionObject[]
78+
*/
79+
private $cachedOrderedActions = null;
80+
7481
/**
7582
* TestObject constructor.
7683
*
@@ -255,8 +262,12 @@ public function getCustomData()
255262
*/
256263
public function getOrderedActions()
257264
{
258-
$mergeUtil = new ActionMergeUtil($this->getName(), "Test");
259-
return $mergeUtil->resolveActionSteps($this->parsedSteps);
265+
if ($this->cachedOrderedActions === null) {
266+
$mergeUtil = new ActionMergeUtil($this->getName(), "Test");
267+
$this->cachedOrderedActions = $mergeUtil->resolveActionSteps($this->parsedSteps);
268+
}
269+
270+
return $this->cachedOrderedActions;
260271
}
261272

262273
/**

0 commit comments

Comments
 (0)