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:
Check the live chart (performance comparison) for more details: http://zordius.github.io/HandlebarsTest/
-
php 5.3+
-
[optional] nodejs04+ and handlebars for fixture generation. (See How to test)
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.
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
- 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.
- Prepare:
git submodule init
git submodule update
- install nodejs04+
- install npm
- install handlebars:
npm install handlebars
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.
- bin/hbreport