Corion / WWW-Mechanize-Chrome

automate the Chrome browser

Home Page:https://metacpan.org/release/WWW-Mechanize-Chrome

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VERY slow on xpath getting TDs of a TR

aimass opened this issue · comments

Hi there!

If there's a mailing list pls. let me know and I'll post the discussion there.

This is taking 2 to 3 seconds on average:
my @cells = $mech->xpath('.//td', node => $rows[$row_index]);

what is making it so slow ?? Is there a way to speed this?

TIA!

--
Alex

UPDATE: the time seems to be proportional to the number of rows. The 2-3 second timing is for a table with 450 rows and 12 columns. On a table with 120 rows, it's less than a second.
Speculating: it would seem that relative to node xpath has some bug and may be scanning the whole table each time.

See also this post. Most helpful would be a short, self-contained script to reproduce the issue.

Sure thing, I'll try to replicate the issue with some public site that has a table with a few hundred records, and follow up here and on PM.BTW, I actually wrote that post on PM ;-)

I updated that post and added a workaround at the end combining W::M::Chrome xpath to find the table node and then HTML::Tree to parse the table. I think this actually a good approach and reduces the Chrome overhead anyways.