Skip to content

Improve performance parsing quoted attributes#798

Merged
minad merged 2 commits intoslim-template:masterfrom
odlp:master
Feb 2, 2018
Merged

Improve performance parsing quoted attributes#798
minad merged 2 commits intoslim-template:masterfrom
odlp:master

Conversation

@odlp
Copy link
Contributor

@odlp odlp commented Jan 26, 2018

Whilst benchmarking a Rails app with memory bloat issues, I noticed a small improvement which could be made to Parser#parse_attributes

Changes:

  • Adds static quoted attributes to the .slim / .haml / .erb benchmark templates.
  • Moves creation of splat prefix regex to the Parser initialization, rather than each invocation of Parser#parse_attributes.

Local benchdiff results:

                    user     system      total        real
------------------------------------------------------Parse
After patch:    2.650000   0.010000   2.660000 (  2.660088)
Before patch:   2.930000   0.010000   2.940000 (  2.936652)
Improvement: 9%

-----------------------------------------------------Render
After patch:    0.840000   0.000000   0.840000 (  0.840143)
Before patch:   0.840000   0.000000   0.840000 (  0.838565)
Improvement: 0%

@minad minad merged commit 5459443 into slim-template:master Feb 2, 2018
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.

2 participants