Version 37 (modified by cmlenz, 17 years ago) (diff) |
---|
Performance of the Genshi Template Engine
The directory examples/bench has some very simple benchmarks to compare the performance of Genshi to other template engines.
It should be noted that text-based template engines generally have a lot less work to do than XML-based ones, simply because their functionality is limited to processing text as opposed to processing markup.
basic benchmark
The basic.py benchmark is based on a relatively simple template that includes a lot of the common templating constructs, such as includes/inheritance, looping, conditionals, macros, etc.
All tests run under Python 2.4.4 on Mac OS X (iMac 2.16 GHz).
Template Engine | Rendering time (less is better) | Notes |
Genshi | 2.65 ms | Genshi markup template |
Genshi (Text) | 0.98 ms | The text-based template engine included with Genshi |
Kid | 6.16 ms | Kid templates are compiled to Python byte-code. The cElementTree implementation was used for this test, although using the Python implementation doesn't appear to make a significant difference. |
Django | 1.38 ms | Text-based template engine that comes with the Django framework. |
Clearsilver | 0.30 ms | ClearSilver is a text-based template engine written in C. |
Mako | 0.31 ms | Text-based template engine written in Python |
SimpleTAL | 2.84 ms | Another XML-based template engine written in Python, based on the Zope template engine (TAL). |
The test template is rather simple right now and doesn't make much use of the advanced features provided by either Genshi or Kid, because then it would be impossible to implement an equivalent template using other template languages.
bigtable benchmark
The bigtable.py benchmark renders a large HTML table (with 1000 rows and 10 columns) in two nested loops, where each cell contains a variable reference. This basically measures the raw throughput of the template engine, while not using any advanced features.
Template Engine | Rendering time (less is better) | Notes |
Genshi | 390 ms | Genshi markup template |
Genshi (Text) | 197 ms | The text-based template engine included with Genshi |
Kid | 1101 ms | |
Django | 474 ms | |
Mako | 96 ms | |
ElementTree | 293 ms | Not a template engine: the benchmark simply constructs the XML tree in memory and serializes it. |
cElementTree | 179 ms | Not a template engine: the benchmark simply constructs the XML tree in memory and serializes it. |
Clearsilver | 83 ms |
Note that both ET and cET are using Python code for serialization.
Another benchmark
There's another simple benchmark in the Genshi repository: examples/basic. That example is however only implemented for Genshi and Kid, as it makes use of features not found in other template languages. Here are the numbers:
Template Engine | Rendering time (less is better) | Notes |
Genshi | 2.89 ms | |
Kid | 6.93 ms |