stencilproject / Stencil

Stencil is a simple and powerful template language for Swift.
https://stencil.fuller.li
BSD 2-Clause "Simplified" License
2.34k stars 221 forks source link

Optimise Scanner performance #207

Closed trametheka closed 5 years ago

trametheka commented 6 years ago

Our project has a few larger templates. After going from Swift 3.1 to 4.1, we noticed a huge performance hit and narrowed it down to here. Under one files test case we are seeing improvements from over 8 seconds down to ~0.15 seconds on our Ubuntu server, and ~0.6 seconds down to ~0.15 on macOS. We are seeing about this performance ratio across all files.

This pull also includes the original scan(until: [String]) function rewritten, but this is about twice as slow as the scanForTokenStart approach.

Open to modifying if required.

kylef commented 6 years ago

Since this drops Swift 3 support, I'd like to get one final Swift 3 compatible release out before taking a look and benchmarking this. Thanks for the contribution @trametheka just wanted to update you on status.

yonaskolb commented 5 years ago

I'd be keen to get this in, and drop Swift 3 support for next release. @trametheka could you rebase this?

trametheka commented 5 years ago

I'm afraid I no longer use stencil @yonaskolb and don't really have the time at the moment I'm sorry. You're certainly welcome to use the code in this PR if you can rebase it yourself. I actually forgot this PR was here.

Liquidsoul commented 5 years ago

Hey @yonaskolb 👋

226 may be the rebase of this you wished for 😉