Optimize extends

This commit is contained in:
bzick
2013-06-08 00:08:00 +04:00
parent f42d0cff5d
commit a515c8e969
13 changed files with 275 additions and 113 deletions

View File

@ -5,6 +5,8 @@ To start benchmark run script `benchmark/run.php`.
### Smarty3 vs Twig vs Cytro
PHP 5.4.11
Print varaibles
smarty3: !compiled and !loaded 8.7919 sec, 21.1 MiB
@ -15,9 +17,9 @@ To start benchmark run script `benchmark/run.php`.
twig: compiled and !loaded 0.0337 sec, 16.1 MiB
twig: compiled and loaded 0.0027 sec, 16.1 MiB
cytro: !compiled and !loaded 1.0142 sec, 8.8 MiB
cytro: compiled and !loaded 0.0167 sec, 6.1 MiB
cytro: compiled and loaded 0.0024 sec, 6.1 MiB
cytro: !compiled and !loaded 1.0142 sec, 8.8 MiB
cytro: compiled and !loaded 0.0167 sec, 6.1 MiB
cytro: compiled and loaded 0.0024 sec, 6.1 MiB
Iterates array
@ -29,9 +31,9 @@ To start benchmark run script `benchmark/run.php`.
twig: compiled and !loaded 0.0605 sec, 2.9 MiB
twig: compiled and loaded 0.0550 sec, 2.9 MiB
cytro: !compiled and !loaded 0.0093 sec, 3.0 MiB
cytro: compiled and !loaded 0.0033 sec, 2.4 MiB
cytro: compiled and loaded 0.0027 sec, 2.4 MiB
cytro: !compiled and !loaded 0.0093 sec, 3.0 MiB
cytro: compiled and !loaded 0.0033 sec, 2.4 MiB
cytro: compiled and loaded 0.0027 sec, 2.4 MiB
templates inheritance
@ -43,10 +45,18 @@ To start benchmark run script `benchmark/run.php`.
twig: compiled and !loaded 0.0255 sec, 6.3 MiB
twig: compiled and loaded 0.0038 sec, 6.3 MiB
cytro: !compiled and !loaded 0.1222 sec, 3.9 MiB
cytro: compiled and !loaded 0.0004 sec, 2.4 MiB
cytro: compiled and loaded 0.0000 sec, 2.4 MiB
cytro: !compiled and !loaded 0.1222 sec, 3.9 MiB
cytro: compiled and !loaded 0.0004 sec, 2.4 MiB
cytro: compiled and loaded 0.0000 sec, 2.4 MiB
* **!compiled and !loaded** - template engine object created but parsers not initialized and templates not compiled
* **compiled and !loaded** - template engine object created, template compiled but not loaded
* **compiled and loaded** - template engine object created, template compiled and loaded
* **compiled and loaded** - template engine object created, template compiled and loaded
### Stats
| Template Engine | Files | Classes | Lines |
| --------------- | ------:| --------:| ------:|
| Smarty3 (3.1.13)| 320 | 190 | 55095 |
| Twig (1.13.0) | 162 | 131 | 13908 |
| Cytro (1.0.1) | 9 | 16 | 3899 |

49
docs/ext/inheritance.md Normal file
View File

@ -0,0 +1,49 @@
Inheritance algorithm
=====================
Variant #1. Sunny.
| level.2.tpl | b1 | add new block | `$tpl->block['b1'] = $content;`
| level.2.tpl | b1 | rewrite block | `$tpl->block['b1'] = $content;`
| level.1.tpl | b1 | skip because block exists | `if(!isset($tpl->block['b1'])) $tpl->block['b1'] = $content;`
| use.tpl | b1 | skip because block exists | `if(!isset($tpl->block['b1'])) $tpl->block['b1'] = $content;`
| use.tpl | b2 | add new block | `$tpl->block['b2'] = $content;`
| level.1.tpl | b2 | rewrite block | `$tpl->block['b2'] = $content;`
| parent.tpl | b1 | get block from stack
| parent.tpl | b2 | get block from stack
| parent.tpl | b3 | get own block
------Result--------
| level.2.tpl | b1 |
| level.1.tpl | b2 |
Variant #2. Сloudy.
| level.2.tpl | b1 | add new block
| level.1.tpl | b1 | skip because block exists
| use.tpl | b1 | skip because block exists
| use.tpl | b2 | add new block
| level.1.tpl | b2 | rewrite block
| $parent | b1 | dynamic extend
------Result--------
| level.2.tpl | b1 |
| level.1.tpl | b2 |
Variant #3. Rain.
Variant #4. Tornado.
Error Info (x2) :
Exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '839621621,839622021)' at line 1
Query: SELECT `image_id`, `filename` FROM `s3_image_version` WHERE `format_id`=1 AND `image_id` IN (,839621621,839622021)
#0 /www/oml.ru/s3/lib/class.db.php(480): Db::parseError('SELECT `image_i...')
#1 /www/oml.ru/s3/forms/class.shop2.product.form.php(225): Db::query('SELECT `image_i...')
#2 /www/oml.ru/s3/lib/class.form.php(2390): Shop2ProductForm->fillControls()
#3 /www/oml.ru/s3/lib/class.form.php(1444): Form->execute()
#4 /www/oml.ru/public/my/s3/data/shop2_product/edit.cphp(44): Form->display(Object(Smarty), 'form.ajax.tpl')
#5 {main}
Place: /www/oml.ru/s3/lib/class.db.php:607
Time: 2013-06-05 03:54:51
Url: http://agyumama.ru/my/s3/data/shop2_product/edit.cphp?shop_id=196421&ver_id=636664&access=u%3B270377&popup=1&product_id=89445221&rnd=9296&xhr=1

View File

@ -10,6 +10,8 @@ Documentation
* [Callbacks and filters](./callbacks.md)
* [Operators](./operators.md)
***
### Modifiers
[Usage](./syntax.md#modifiers)
@ -28,6 +30,8 @@ Documentation
`strtotime`, `gettype`, `is_double`, `ip2long`, `long2ip`, `strip_tags`, `nl2br`
* or [add](./ext/mods.md) your own
***
### Tags
[Usage](./syntax.md#tags)
@ -46,6 +50,8 @@ Documentation
* [autotrim](./tags/autotrim.md)
* or [add](./ext/tags.md) your own
***
### Extends
* [Add tags](./ext/tags.md)

View File

@ -54,6 +54,8 @@ Tag {extends} [RU]
### {parent}
Planned. Not supported yet.
```smarty
{block 'block1'}
content ...