bobthecow / mustache.php

A Mustache implementation in PHP.
http://mustache.github.io/
MIT License
3.25k stars 421 forks source link

lightncandy performance #133

Open gzip opened 11 years ago

gzip commented 11 years ago

Not an issue per se but I wonder if you can comment on this: https://github.com/zordius/HandlebarsTest#quick-conclusion

It looks like mustache.php is supporting more features in the compiled templates like context resolution and strings vs methods, so it's not really apples to apples. Just wanted your take on it.

bobthecow commented 11 years ago

It's easy to be fast when you don't actually implement the templating language :)

Compare:

To:

bobthecow commented 11 years ago

Another:

Vs:

bobthecow commented 11 years ago

Okay. I got the benchmark running locally, and to be fair, it's not as bad as it initially looked. Apparently they've improved their library a bit, so it doesn't just forget to render quite as many bits now.

bobthecow commented 11 years ago

I wrote another benchmark and got similar results:

bench

Unfortunately, not all mustaches are created equal:

spec

The black squares are specs that hit a fatal error: i.e. PHP just died. The red ones are exceptions: nothing was rendered at all. The striped red blocks returned a result, but did not match the expected output.

Note that these benchmarks and tests were against the official Mustache spec, which is a collection of small templates and data. I'm planning to add some larger benchmarks too see how performance changes when confronted with a more complex template, but based on the HandlebarsTest above, I'd say they'll probably be pretty comparable.

gzip commented 11 years ago

This looks like a very telling comparison. There are some discernible patterns amongst the libs. It would be interesting to see which parts of the spec generate the errors; fatal, empty, or otherwise. Looking forward to further information.

bobthecow commented 11 years ago

Yep. I'll definitely be releasing this once I have a chance to make it more presentable :)

The right half of the top row is delimiter changes. The end of the third row, start of the fourth is partials. I believe mustache-php does not implement them, but tries to throw an exception class that does not exist (hence the fatal error). Handlebars works just fine, but it isn't quite spec compliant (hence the red stripes). I'd guess that one's due to whitespace. And I haven't looked into phly_mustache to know why it's hitting a fatal error.

rafi commented 11 years ago

Looking forward for more compares. Lightncandy seems very fast, but it doesn't support partials ..

tlovett-rmn commented 9 years ago

@bobthecow Do you still have the code, etc. for your benchmarks and spec compliance tests? I'm interested to see how all the frameworks compare now.

bobthecow commented 9 years ago

Somewhere. I've changed computers once and wiped my computer twice since then, but I might be able to dig it up :)

Yoskaldyr commented 8 years ago

@bobthecow How can I check spec compliance by self? Or where can I find these feature coverage tests? Because I don't need full mustache features and want to choose library that better fits my needs.

mAAdhaTTah commented 7 years ago

FWIW, I merged a PR into Handlebars.php that may address some of the spec compliance issues mentioned above.