xhpy
xhpy copied to clipboard
String concatenation should be replaced with join()
Here are the results of a modified spitfire test (https://code.google.com/p/spitfire/source/browse/trunk/tests/perf/bigtable.py) on my machine using
def run_test(t):
xhpy.pylib.core.ENABLE_VALIDATION = False
table = <table/>
for row in t:
tr = <tr/>
for col in row.itervalues():
tr.appendChild(<td>{col}</td>)
table.appendChild(tr)
return str(table)
1000x10 table (the default):
Mako Template 23.93 ms
StringIO 31.38 ms
cStringIO 5.48 ms
list concat 11.71 ms
xhpy 120.58 ms
10x10000 table:
Mako Template 247.07 ms
StringIO 310.89 ms
cStringIO 57.64 ms
list concat 44.02 ms
xhpy 5738.22 ms
10x100000 table:
Mako Template 2393.53 ms
StringIO 3110.47 ms
cStringIO 558.29 ms
list concat 409.80 ms
xhpy 1733126.09 ms
While the last one might not be a totally realistic example, the first two are, and 5 seconds is not a reasonable render time. I can submit a pull request if you let me know how to use the pdb within xhpy elements. It skips most things for some reason.
Coincidentally, I think you may have been my frosh leader in 2008. I started working on the same thing for a couple of days before I found yours. Great work!
Apologies for the delayed reply - things have been insanely busy lately on the work/life front.
This is a good point. I haven't put much effort into optimizing XHPy, so there's bound to be some low-hanging fruit around.
Using join() shaves ~50% of rendering time in the 10x10000 case. From a quick profiling run, the rest of the overhead is more spread out: init() for all those document nodes, instanceof as it collapses :x:element instances into strings...
On Wed, Sep 12, 2012 at 4:14 PM, stoarca [email protected] wrote:
Here are the results of a modified spitfire test ( https://code.google.com/p/spitfire/source/browse/trunk/tests/perf/bigtable.py) on my machine using
def run_test(t): xhpy.pylib.core.ENABLE_VALIDATION = False table =
for row in t: tr =
for col in row.itervalues(): tr.appendChild( {col} ) table.appendChild(tr) return str(table)1000x10 table (the default):
Mako Template 23.93 ms StringIO 31.38 ms cStringIO 5.48 ms list concat 11.71 ms xhpy 120.58 ms
10x10000 table:
Mako Template 247.07 ms StringIO 310.89 ms cStringIO 57.64 ms list concat 44.02 ms xhpy 5738.22 ms
10x100000 table:
Mako Template 2393.53 ms StringIO 3110.47 ms cStringIO 558.29 ms list concat 409.80 ms xhpy 1733126.09 ms
While the last one might not be a totally realistic example, the first two are, and 5 seconds is not a reasonable render time. I can submit a pull request if you let me know how to use the pdb within xhpy elements. It skips most things for some reason.
Coincidentally, I think you may have been my frosh leader in 2008. I started working on the same thing for a couple of days before I found yours. Great work!
— Reply to this email directly or view it on GitHubhttps://github.com/candu/xhpy/issues/4.