Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Tornado 2.0 template benchmark #314

Closed
allisson opened this Issue Jul 27, 2011 · 2 comments

Comments

Projects
None yet
2 participants

Hello, I believe there is a performance issue with template render in version 2.0 as i see in this benchmark: https://github.com/mitsuhiko/jinja2/blob/master/examples/bench.py

Results for tornado 1.2.1

                   Template Engine BigTable Benchmark                       

This benchmark compares some python templating engines with Jinja 2 so
that we get a picture of how fast Jinja 2 is for a semi real world
template.  If a template engine is not installed the test is skipped.

jinja               0.0113 seconds
mako                0.0120 seconds
tornado             0.0091 seconds
tenjin              *not installed*
spitfire            *not installed*
django              0.4031 seconds
genshi              *not installed*
cheetah             *not installed*
chameleon           *not installed*
chameleon_genshi    *not installed*

WARNING: The results of this benchmark are useless to compare the
performance of template engines and should not be taken seriously in any
way.  It's testing the performance of simple loops and has no real-world
usefulnes.  It only used to check if changes on the Jinja code affect
performance in a good or bad way and how it roughly compares to others.

Results for tornado 2.0

                   Template Engine BigTable Benchmark                       

This benchmark compares some python templating engines with Jinja 2 so
that we get a picture of how fast Jinja 2 is for a semi real world
template.  If a template engine is not installed the test is skipped.

jinja               0.0113 seconds
mako                0.0120 seconds
tornado             0.0617 seconds
tenjin              *not installed*
spitfire            *not installed*
django              0.3937 seconds
genshi              *not installed*
cheetah             *not installed*
chameleon           *not installed*
chameleon_genshi    *not installed*

WARNING: The results of this benchmark are useless to compare the
performance of template engines and should not be taken seriously in any
way.  It's testing the performance of simple loops and has no real-world
usefulnes.  It only used to check if changes on the Jinja code affect
performance in a good or bad way and how it roughly compares to others.

It's a big diference between 1.2.1 and 2.0 (~ 6.8x)

Owner

bdarnell commented Jul 27, 2011

This is not too surprising since 2.0 introduced autoescaping for templates by default (which I don't think jinja or mako do), as well as some more unicode-related checks and conversions for python3 compatibility. I'll take a look in a profiler and see if there's any obvious room for improvement, but it's probably not going to get as fast as it was in 1.2.

Owner

bdarnell commented Jul 28, 2011

I've sped up the xhtml_escape function, which on my machine takes the benchmark as a whole from 49ms to 32ms. Turning off autoescape takes it down to 12ms, which is not that far from the 1.2 performance. I can squeeze a little more speed out of it by making assumptions about whether byte strings or unicode strings are more common, but that's probably just overfitting to the benchmark, so I'm not committing any of that.

@bdarnell bdarnell closed this Jul 28, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment