Skip to content
Snippets Groups Projects
Commit c8230cba authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[TASK] Reduce memory usage of a greedy unit test

> Build/Scripts/runTests.sh

Before:
Memory: 469.06 MB

After:
Memory: 373.02 MB

Reason: phpunit executes data providers early and keeps
data sets in memory. The "xml parser big content" tests
create megabytes of data kept in memory. Moving the data
generation from data providers to the test execution
reduces overall memory usage significantly.

Resolves: #104076
Releases: main, 12.4, 11.5
Change-Id: I0ad49824fc1d4c309158b74474853d36af22ffb5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84668


Reviewed-by: default avatarAndreas Kienast <a.fernandez@scripting-base.de>
Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarAndreas Kienast <a.fernandez@scripting-base.de>
parent 25aedf4d
Branches
Tags
No related merge requests found
......@@ -347,52 +347,28 @@ final class Typo3XmlParserTest extends UnitTestCase
);
}
/**
* @return array[]
*/
public static function decodeHandlesBigXmlContentDataProvider(): array
{
return [
'1mb' => [
'<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<T3FlexForms>
<data>
<field index="settings.persistenceIdentifier">
<value index="vDEF">' . str_repeat('1', 1024 * 1024) . '</value>
</field>
</data>
</T3FlexForms>',
str_repeat('1', 1024 * 1024),
],
'5mb' => [
'<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<T3FlexForms>
<data>
<field index="settings.persistenceIdentifier">
<value index="vDEF">' . str_repeat('1', 5 * 1024 * 1024) . '</value>
</field>
</data>
</T3FlexForms>',
str_repeat('1', 5 * 1024 * 1024),
],
'10mb' => [
'<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<T3FlexForms>
<data>
<field index="settings.persistenceIdentifier">
<value index="vDEF">' . str_repeat('1', 10 * 1024 * 1024) . '</value>
</field>
</data>
</T3FlexForms>',
str_repeat('1', 10 * 1024 * 1024),
],
'1mb' => [1],
'5mb' => [5],
'10mb' => [10],
];
}
#[DataProvider('decodeHandlesBigXmlContentDataProvider')]
#[Test]
public function decodeHandlesBigXmlContent(string $input, string $testValue): void
public function decodeHandlesBigXmlContent(int $megabytes): void
{
$input = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<T3FlexForms>
<data>
<field index="settings.persistenceIdentifier">
<value index="vDEF">' . str_repeat('1', $megabytes * 1024 * 1024) . '</value>
</field>
</data>
</T3FlexForms>';
$testValue = str_repeat('1', $megabytes * 1024 * 1024);
$xmlDecoder = new Typo3XmlParser();
$expected = [
'data' => [
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment