malgorithms/toffee — pull request #12 by apgwoz (2013-02-01 22:52:05+00:00)
Title: Closure compile with sandbox cache

As I mentioned in a personal email, this significantly speeds up rendering by compiling templates to functions rather than to scripts that must be executed in an execution context. I've tested this within the app we're using toffee for and am reasonably confident that I have not screwed up anything with these changes.

For timing comparison (I don't have *real* benchmark numbers, just the test output timing):

**NEW**

Regular Engine: SUCCESS for 16 cold tests in 483ms (30.19ms/test)
Regular Engine: SUCCESS for 480 hot tests in 89ms (0.19ms/test)
Minimized (browser) Engine: SUCCESS for 16 cold tests in 1116ms (69.75ms/test)
Minimized (browser) Engine: SUCCESS for 480 hot tests in 77ms (0.16ms/test)

**OLD**

Regular Engine: SUCCESS for 16 cold tests in 522ms (32.63ms/test)
Regular Engine: SUCCESS for 480 hot tests in 819ms (1.71ms/test)
Minimized (browser) Engine: SUCCESS for 16 cold tests in 1131ms (70.69ms/test)
Minimized (browser) Engine: SUCCESS for 480 hot tests in 800ms (1.67ms/test)

That's pretty significant, though the test suite isn't insanely complex. In our app, we seem to go from ~30ms to about ~10ms (for example), on my local machine. We make lots of use of partials and includes, which has been a huge pain point for us.