Permalink
Browse files

Merge pull request #2203 from camspiers/config-memory

Improve memory performance when generating config static and class caches
  • Loading branch information...
2 parents 10b5517 + 2d30592 commit 3bfb82d25fd08e6421074fd3b9bf3ebc5d73f601 @chillu chillu committed Jul 8, 2013
@@ -273,6 +273,15 @@ public function getModules() {
return $modules;
}
+ /**
+ * Used to set up files that we want to exclude from parsing for performance reasons.
+ */
+ protected function setDefaults()
+ {
+ $this->classes['sstemplateparser'] = FRAMEWORK_PATH.'/view/SSTemplateParser.php';
+ $this->classes['sstemplateparseexception'] = FRAMEWORK_PATH.'/view/SSTemplateParser.php';
+ }
+
/**
* Completely regenerates the manifest file.
*
@@ -289,10 +298,12 @@ public function regenerate($cache = true) {
$this->$reset = array();
}
+ $this->setDefaults();
+
$finder = new ManifestFileFinder();
$finder->setOptions(array(
'name_regex' => '/^(_config.php|[^_].*\.php)$/',
- 'ignore_files' => array('index.php', 'main.php', 'cli-script.php'),
+ 'ignore_files' => array('index.php', 'main.php', 'cli-script.php', 'SSTemplateParser.php'),
'ignore_tests' => !$this->tests,
'file_callback' => array($this, 'handleFile'),
'dir_callback' => array($this, 'handleDir')
@@ -100,7 +100,7 @@ public function regenerate($cache = true) {
$finder = new ManifestFileFinder();
$finder->setOptions(array(
'name_regex' => '/^([^_].*\.php)$/',
- 'ignore_files' => array('index.php', 'main.php', 'cli-script.php'),
+ 'ignore_files' => array('index.php', 'main.php', 'cli-script.php', 'SSTemplateParser.php'),
'ignore_tests' => !$this->tests,
'file_callback' => array($this, 'handleFile')
));
@@ -36,17 +36,20 @@ public function testGetItemPath() {
public function testGetClasses() {
$expect = array(
- 'classa' => "{$this->base}/module/classes/ClassA.php",
- 'classb' => "{$this->base}/module/classes/ClassB.php",
- 'classc' => "{$this->base}/module/classes/ClassC.php",
- 'classd' => "{$this->base}/module/classes/ClassD.php"
+ 'classb' => "{$this->base}/module/classes/ClassB.php",
+ 'classa' => "{$this->base}/module/classes/ClassA.php",
+ 'classb' => "{$this->base}/module/classes/ClassB.php",
+ 'classc' => "{$this->base}/module/classes/ClassC.php",
+ 'classd' => "{$this->base}/module/classes/ClassD.php",
+ 'sstemplateparser' => FRAMEWORK_PATH."/view/SSTemplateParser.php",
+ 'sstemplateparseexception' => FRAMEWORK_PATH."/view/SSTemplateParser.php"
);
$this->assertEquals($expect, $this->manifest->getClasses());
}
public function testGetClassNames() {
$this->assertEquals(
- array('classa', 'classb', 'classc', 'classd'),
+ array('sstemplateparser', 'sstemplateparseexception', 'classa', 'classb', 'classc', 'classd'),
$this->manifest->getClassNames());
}
@@ -12,7 +12,7 @@ class NamespacedClassManifestTest extends SapphireTest {
public function setUp() {
parent::setUp();
-
+
$this->base = dirname(__FILE__) . '/fixtures/namespaced_classmanifest';
$this->manifest = new SS_ClassManifest($this->base, false, true, false);
}
@@ -41,25 +41,28 @@ public function testGetClasses() {
'silverstripe\test\classe' => "{$this->base}/module/classes/ClassE.php",
'silverstripe\test\classf' => "{$this->base}/module/classes/ClassF.php",
'silverstripe\test\classg' => "{$this->base}/module/classes/ClassG.php",
- 'silverstripe\test\classh' => "{$this->base}/module/classes/ClassH.php"
+ 'silverstripe\test\classh' => "{$this->base}/module/classes/ClassH.php",
+ 'sstemplateparser' => FRAMEWORK_PATH."/view/SSTemplateParser.php",
+ 'sstemplateparseexception' => FRAMEWORK_PATH."/view/SSTemplateParser.php"
);
-
+
$this->assertEquals($expect, $this->manifest->getClasses());
}
public function testGetClassNames() {
$this->assertEquals(
- array('silverstripe\test\classa', 'silverstripe\test\classb', 'silverstripe\test\classc',
- 'silverstripe\test\classd', 'silverstripe\test\classe', 'silverstripe\test\classf',
- 'silverstripe\test\classg', 'silverstripe\test\classh'),
+ array('sstemplateparser', 'sstemplateparseexception', 'silverstripe\test\classa',
+ 'silverstripe\test\classb', 'silverstripe\test\classc', 'silverstripe\test\classd',
+ 'silverstripe\test\classe', 'silverstripe\test\classf', 'silverstripe\test\classg',
+ 'silverstripe\test\classh'),
$this->manifest->getClassNames());
}
public function testGetDescendants() {
$expect = array(
'silverstripe\test\classa' => array('silverstripe\test\ClassB', 'silverstripe\test\ClassH'),
);
-
+
$this->assertEquals($expect, $this->manifest->getDescendants());
}
@@ -109,7 +112,7 @@ public function testGetConfigs() {
$expect = array("{$this->base}/module/_config.php");
$this->assertEquals($expect, $this->manifest->getConfigs());
}
-
+
public function testGetModules() {
$expect = array(
"module" => "{$this->base}/module",

0 comments on commit 3bfb82d

Please sign in to comment.