= Performance of the Genshi Template Engine = The directory [source:/trunk/examples/bench/ 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 [source:/trunk/examples/bench/basic.py 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.3 on Mac OS X (!MacBook 2GHz). || '''Template Engine''' || '''Rendering time (less is better)''' || '''Notes''' || || Genshi || 3.95 ms || || || [http://www.clearsilver.net/ Clearsilver] || 0.33 ms || !ClearSilver is a text-based template engine written in C. || || [http://www.djangoproject.com/documentation/templates/ Django] || 1.84 ms || Text-based template engine that comes with the [http://www.djangoproject.com/ Django] framework. || || [http://kid-templating.org/ Kid] || 6.97 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. || || [http://www.owlfish.com/software/simpleTAL/ SimpleTAL] || 3.13 ms || Another XML-based template engine written in Python, based on the [http://www.zope.org/ 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 [source:/trunk/examples/bench/bigtable.py 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 || 510 ms || || || [http://kid-templating.org/ Kid] || 1235 ms || || || [http://www.djangoproject.com/documentation/templates/ Django] || 357 ms || || || [http://effbot.org/zone/element-index.htm ElementTree] || 329 ms || ''Not a template engine'': the benchmark simply constructs the XML tree in memory and serializes it. || || [http://effbot.org/zone/celementtree.htm cElementTree] || 202 ms || ''Not a template engine'': the benchmark simply constructs the XML tree in memory and serializes it. || || [http://www.clearsilver.net/ Clearsilver] || 102 ms || || ''Note that both ET and cET are using Python code for serialization.'' == Another benchmark == There's another simple benchmark in the Genshi repository: [source:/trunk/examples/basic/ examples/basic]. That example is however only implemented for Genshi and Kid. Here are the numbers: || '''Template Engine''' || '''Rendering time (less is better)''' || '''Notes''' || || Genshi || 3.15 ms || || || [http://kid-templating.org/ Kid] || 7.94 ms || || I'm not quite sure why the difference between Genshi and Kid is so much more drastic in this example compared to the above. It does define more (and slightly more sophisticated) match templates, which would suggest that Genshi implements those more efficiently. However, that's just a hypothesis.