Posts

Showing posts from August, 2011

Python templating comparison by memory consumption

Another comparison between:

standard formatting;more advanced standard string.template;MakoGenshiJinja2 Here the code I used for measuring: #!/usr/bin/env python import sys NAME = 'name' def render1(): template = "<p>Hello %s!</p>" return template % NAME def render2(): from string import Template template = Template("<p>Hello ${name}!</p>") return template.substitute(dict(name=NAME)) def render3(): from mako.template import Template template = Template("<p>Hello ${name}!</p>") return template.render(name=NAME) def render4(): from genshi.template import MarkupTemplate tmpl = MarkupTemplate('<p>Hello $name!</p>') stream = tmpl.generate(name=NAME) return stream.render('xhtml') def render5(): from jinja2 import Template template = Template('<p>Hello {{ name }}!</p>')…

Web application framework comparison by memory consumption

Memory consumption is slightly specific to my area of software development now, but I did some research recently and maybe these results can be useful for others. Of course, I know that precious comparison is very difficult to carry out, but actually I needed only overall picture. And let me admit that results are pretty interesting and even frustrated (at least for me).

As a basis I took so-starving project, and measured initial RSS (Resident Set Size) of the each process (local development webservers). Platform: x86_64 Linux (latest Ubuntu with all updates).

As a reference, here is the RSS of the interpreters in interactive console mode:

InterpreterVersionRSS (kB)stackless python2.6.43916ruby (via irb)1.8.74664python2.7.15624php5.3.56924v8 (via node.js shell)2.5.9.98796
One more reference - the most simplest WSGI app (example in the Python documentation). It's RSS: 7336Kb, so I assume it's almost impossible to consume less memory without additional tweaks and optimizatio…