Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String concatenation should be replaced with join() #4

Open
stoarca opened this issue Sep 12, 2012 · 1 comment
Open

String concatenation should be replaced with join() #4

stoarca opened this issue Sep 12, 2012 · 1 comment

Comments

@stoarca
Copy link

stoarca commented Sep 12, 2012

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!

@candu
Copy link
Owner

candu commented Sep 20, 2012

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
❌element instances into strings...

On Wed, Sep 12, 2012 at 4:14 PM, stoarca notifications@github.com 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()
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//issues/4.

{col}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants