I can not reproduce your results. I used your test files and created an empty Django project with
django-admin.py startproject foo && cd foo
With Tornado 2.1.1, I get a consistent 45 ms per iteration. With Django 1.3.1, I get 480 ms per iteration.
For Jinja2, I conducted 4 tests. 2.5.2 and 2.6 with and without MarkupSafe :
2.5.2
- w / MarkupSafe: 19 ms
- w / o: 14ms
2.6
I'm curious that MarkupSafe actually slows down 2.5.2, significantly (although it is still only 5 ms), although that may be because I don't have the version of MarkupSafe that was modern with Jinja2 2.5.2.
Your test also does not use Jinja2 cache code, which can significantly speed it up. I'm not sure if Django has a template cache or not - I know that it has fragment caching, but I'm not sure about that.
Update: I tried the built-in MemcachedBytecodeCache , and it slowed down Jinja2 2.6 to 22ms, perhaps because the template is simple, network activity is worse than creating it. With a cache in RAM, these were the same 14 ms.
source share