Skip to content

[FrameworkBundle] Improved TemplateNameParser performance#7812

Merged
fabpot merged 1 commit intosymfony:masterfrom
webmozart:improve-name-parser
Apr 23, 2013
Merged

[FrameworkBundle] Improved TemplateNameParser performance#7812
fabpot merged 1 commit intosymfony:masterfrom
webmozart:improve-name-parser

Conversation

@webmozart
Copy link
Copy Markdown
Contributor

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

Performance test in symfony-standard:

<?php

use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser;

require __DIR__.'/vendor/autoload.php';
require __DIR__.'/app/AppKernel.php';

$kernel = new AppKernel('dev', true);
$kernel->boot();
$parser = new TemplateNameParser($kernel);

$time = microtime(true);

for ($i = 0; $i < 50; ++$i) {
    $parser->parse("AcmeDemoBundle:Foo:bar$i.html.twig");
}

echo "Time:   " . (microtime(true) - $time)*1000 . "ms\n";
echo "Memory: " . memory_get_peak_usage(true)/(1024*1024) . "MB\n";

Before:

Time:   3.80706787109ms
Memory: 1.5MB

After:

Time:   3.13401222229ms
Memory: 1.5MB

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'/^([^:]*):([^:]*):(.+)\.([^\.]++)\.([^\.]++)$/' could be slightly faster

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really notice a difference. Interesting feature though, didn't know about double plus! :)

fabpot added a commit that referenced this pull request Apr 23, 2013
This PR was merged into the master branch.

Discussion
----------

[FrameworkBundle] Improved TemplateNameParser performance

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Performance test in symfony-standard:
```php
<?php

use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser;

require __DIR__.'/vendor/autoload.php';
require __DIR__.'/app/AppKernel.php';

$kernel = new AppKernel('dev', true);
$kernel->boot();
$parser = new TemplateNameParser($kernel);

$time = microtime(true);

for ($i = 0; $i < 50; ++$i) {
    $parser->parse("AcmeDemoBundle:Foo:bar$i.html.twig");
}

echo "Time:   " . (microtime(true) - $time)*1000 . "ms\n";
echo "Memory: " . memory_get_peak_usage(true)/(1024*1024) . "MB\n";
```

Before:
```
Time:   3.80706787109ms
Memory: 1.5MB
```

After:
```
Time:   3.13401222229ms
Memory: 1.5MB
```

Commits
-------

f092c7f [FrameworkBundle] Improved TemplateNameParser performance
@fabpot fabpot closed this Apr 23, 2013
@fabpot fabpot merged commit f092c7f into symfony:master Apr 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants