in reply to Re^2: WWW::Mechanize::Firefox latency using RemoteObject
in thread WWW::Mechanize::Firefox latency using RemoteObject

This is just as you suspected - each attribute access involves at least one roundtrip over TCP from Perl to Firefox and back. There is little you can do except avoid accessing Javascript data from Perl, or to make bulk requests.

Likely, the CPU time gets split up between Firefox and Perl and the kernel for the Network, and I'm not sure how your monitoring accounts for time spent in the kernel.

Update: If you start to optimize your application and try to reduce the accesses to Javascript objects, the object bridge has some counters that might be of help:

stats => { roundtrip => 0, # total number of roundtrips fetch => 0, # number of attribute fetches store => 0, # number of attribute stores callback => 0, # number of callbacks triggered },
use Data::Dumper; my $repl = $mech->repl; warn Dumper $repl->{stats};

Replies are listed 'Best First'.
Re^4: WWW::Mechanize::Firefox latency using RemoteObject
by hansendc (Novice) on Apr 09, 2011 at 23:50 UTC
    Thanks for the stats tip. That will help a bunch.

    So, I did just put my code in a loop. It sits basically pounding on the roundtrip and fetch operations in the stats. Even when this is happening, the CPU is never more than about 25% utilized, total, including perl, firefox and the kernel.

    I'm measuring using vmstat, which accounts for system time nicely. I also did some kernel profiling to make sure nothing in there looked funny. Nothing really sticks out there.