https://github.com/zordius/handlebarstest
Performance tests on Mustache and Handlebars php libs
https://github.com/zordius/handlebarstest
Last synced: about 1 year ago
JSON representation
Performance tests on Mustache and Handlebars php libs
- Host: GitHub
- URL: https://github.com/zordius/handlebarstest
- Owner: zordius
- Created: 2013-01-07T02:40:06.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2022-03-22T00:26:25.000Z (over 4 years ago)
- Last Synced: 2025-05-07T21:02:52.805Z (about 1 year ago)
- Language: PHP
- Homepage: http://zordius.github.io/HandlebarsTest/
- Size: 26.4 MB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
HandlebarsTest
==============
[](https://github.com/zordius/HandlebarsTest/actions/workflows/php.yml) tested PHP: 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0
Performance tests on Mustache and Handlebars php libs. Results can be found here: http://zordius.github.io/HandlebarsTest/ .
Performance results done by others:
* https://github.com/gwicke/TemplatePerf
Current Result
--------------
Check the live chart (performance comparison) for more details: http://zordius.github.io/HandlebarsTest/
Requirements
------------
* php 5.3+
* [optional] nodejs04+ and handlebars for fixture generation. (See How to test)
Quick Conclusion
----------------
Use https://github.com/zordius/lightncandy to compile handlebars in php, because:
* it runs 2~7 times faster than https://github.com/bobthecow/mustache.php
* it runs 2~7 times faster than https://github.com/dingram/mustache-php
* it runs 10~50 times faster than https://github.com/XaminProject/handlebars.php
Detail reports please browse the 'report' directory.
Libraries
---------
Testing targets:
* pure php template with logic commands.
* Mustache.php https://github.com/bobthecow/mustache.php
* mustache-php https://github.com/dingram/mustache-php
* Handlebars.php https://github.com/XaminProject/handlebars.php
* lightncandy https://github.com/zordius/lightncandy
Testing data and templates:
* some fixtures are converted from https://github.com/bobthecow/mustache.php/tree/master/test/fixtures/examples
Directories
-----------
* *cloned*: all cloned library files are placed here.
* *fixture*: all data files for testing are placed here:
* .json : testing data files in json format
* .tmpl : testing template files
* .txt : correct results and library outputs
* .php : lightncandy generated php template
* *inc*: all required php lib files are placed here.
* *bin*: all testing scripts and commands are placed here.
* *report*: all reports generated by bin/hbreport are placed here, in different format.
Feature Comparison
------------------

How to Test
-----------
* Prepare:
```sh
git submodule init
git submodule update
```
1. install nodejs04+
2. install npm
3. install handlebars: `npm install handlebars`
4. `bin/generate-fixture`
* This will generate *.txt files under fixtures.
* These files are generated with handlebars.js.
* All tests will use these txt files as standard answers.
* single lib test
* bin/hbtest libName testFile [testTimes]
* libName can be one of: none , lightncandy , handlebars.php , mustache-php , mustache.php
* testTimes default 100000. When testing on lightncandy, testTimes as even times will testing as best performance, testTimes as odd times will testing as best features.
* Example: bin/hbtest mustache.php fixture/001-simple-vars-001.json
* feature test
* all tests will be executed with FLAG_HANDLEBARS on (turn on all handlebars extensions on mustache)
* Thest tests do not generate any file under report/
* After test end, a feature chart will be outputed on console.
* bin/hbreport 5
* lightncandy will be executed with FLAG_JS enabled
* bin/hbreport 7
* lightncandy will be executed with FLAG_JS and FLAG_STANDALONE enabled.
* bin/hbreport 1
* lightncandy will be executed with FLAG_JS, FLAG_STANDALONE and FLAG_ECHO enabled (to know more about FLAG_BESTPERFORMANCE, read lightncandy document please)
* bin/hbreport F num_of_know_issue
* only test on lightncandy
* exit with (number of detected issues - number of know issues)
* performance test
* bin/hbreport
* This will generate report files under report/
* default test 100000 times on every cases and libs, takes very long time.
* bin/hbreport L
* This will generate report files under report/versions*.json
* Tests on every release/version of lightncandy.
* test 10000 times on every cases.
* Go http://zordius.github.io/HandlebarsTest/versions.html to see results as chart.