Tristan Seligmann ha scritto:
* Manlio Perillo <[EMAIL PROTECTED]> [2006-12-15 13:33:55 +0100]:
[EMAIL PROTECTED]:~/projects/tests/nevow$ python static2.py
9.85 usec/pass
[EMAIL PROTECTED]:~/projects/tests/django$ python static2.py
13.31 usec/pass
Is this python 2.4 or 2.5? The string handling speed-ups in 2.5 have a
fairly substantial impact on Nevow rendering speed, I believe.
Python 2.4.
However Python 2.5 should speed up Django, too.
Nevow for every data object calls inevow.IContainer.child.
The problem can be here, since it is called 25 times (the number of rows
in the table)
That's easy enough to fix, just don't use data specials :)
Right!
class Main(rend.Page):
docFactory = loaders.xmlfile("template3.xhtml")
def render_header(self, ctx, data):
def renderRow(data):
for i in data:
yield tags.th[str(i)]
data = range(COLS)
return ctx.tag[renderRow(data)]
def render_table(self, ctx, data):
def renderRow(data):
for i in data:
yield tags.td[str(i)]
def renderTable(data):
for i in data:
yield tags.tr[renderRow(i)]
data = [
[random.random() for j in range(COLS)]
for i in range(ROWS)
]
return ctx.tag[renderTable(data)]
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:n="http://nevow.com/ns/nevow/0.1"
lang="en" xml:lang="">
<head>
<title>Test Nevow performance</title>
</head>
<body>
<table>
<caption>RandomTable</caption>
<thead>
<tr n:render="header" />
</thead>
<tbody n:render="table" />
</table>
</body>
</html>
[EMAIL PROTECTED]:~/projects/tests/nevow$ python static3.py
75.71 usec/pass
4.5 times faster!
I suspect that using directly flat.flatten is even better but, then,
what's the use of the templating system?
P.S.
Django.template does not escapes string.
If I add the filter escape, performance drops from
33.58 usec/pass to 47.16 usec/pass.
Regards Manlio Perillo
_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web