Skip to content

The Optimizer is slow in loop #84

@char101

Description

@char101

Hi,

When executed in a loop (actually when using phug inside an event-based framework like workerman), the performance of the optimizer is slow (6ms when compared to Fenom 0.1ms).

This can be improved by caching the 2nd parameter to isExpired at https://github.com/phug-php/phug/blob/master/src/Phug/Phug/Phug/Optimizer.php#L130.

In my test, caching the 2nd parameter of isExpired reduced the execution time from 6ms to 0.6ms. Still slower than Fenom's 0.1ms.

The remaining difference of 0.5ms I assume is because Fenom compiles template to an anomyous function + echo compared to pug which uses extract and include.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions