-
Notifications
You must be signed in to change notification settings - Fork 0
Comparison
The following is a general comparison between different engines. It'll be expanded and updated as time allows and new versions of the various engines become available.
Jinja2's statistics vs. Mako, say, indicate that while it doesn't have substantially more individual lines, those individual lines are far, far more complex individually (bytecode size scale difference), and that those lines are arranged with greater Mccabe complexity in the flow control structures. Both generally greater complexity, but also far more specific instances of excessive complexity, including a worst-case that's basically off the chart, despite having theoretically greater internal structure due to the # functions / classes distinction.
Though all evaluated engines except tenjin, which uses module compression techniques to merge multiple modules into one file, organize the code into modules with functionally similar purposes, cinje basically isn't comparable in terms of code density.
Some people just like to watch CPUs burn.
Versions represented:
All tests are run against the pip install
ed code present in the site-packages
directory. Tools utilized:
-
SLoC, Estimated Effort: Generated using David A. Wheeler's
sloccount-2.26
-
Code Complexity:
mccabe==0.4.0
-
Execution Totals:
coverage==4.0.3
Methodologies:
-
Function Count:
find "${PROJECT}" -iname \*.py -exec python -m dis {} \; | grep MAKE_FUNCTION | wc -l
-
Class Count:
find "${PROJECT}" -iname \*.py -exec python -m dis {} \; | grep BUILD_CLASS | wc -l
-
Bytecode Size: Calculated after
python -O2 -m compileall
usage, based on real bytecode file size before block rounding.
Ancillary (sometimes optional, but installed) dependencies:
MarkupSafe==0.23
cinje | Jinja2 | Mako | Tenjin | |
---|---|---|---|---|
Source Files | 26 | 23 | 26 | 1 |
Source Lines of Code | 1076 | 6438 | 5035 | 1366 |
SLoC Per File Average | 41 | 280 | 194 | 1366 |
Number of Functions | 36 | 282 | 164 | 39 [1] |
Number of Classes | 20 | 137 | 80 | 25 [1] |
Average Complexity | 2.755 | 2.962 | 2.578 | 3.131 |
Complexity 95th % | 8 | 9 | 8 | 12 |
Maximum Complexity | 19 | 38 | 22 | 23 |
# > 15 Complexity | 1 | 8 | 4 | 1 |
Bytecode Size (Bytes) | 42541 | 462830 | 197737 | 59891 |
Bytecode Size (KiB) | 42 KiB | 452 KiB | 193 KiB | 58 KiB |
Using full (non-streaming) generation of the 1000-row "bigtable" test, how many individual functions are called and how many times are they called?
cinje | Jinja2 | Mako | Tenjin | |
---|---|---|---|---|
Distinct Functions | 18 | 27 | 37 | 16 |
Function Calls | 84011 | 60020 | 93036 | 123012 |
Note 1: Tenjin "cheats" by bundling multiple dynamically constructed modules within itself; these numbers are not accurate to the actual accessible and/or executed code during runtime.