Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The exact same code on the VPS takes 1m 57s to run. Networking from this VPS is fine, using top I see the CPU is maxed out, when Mojo::DOM-new is called. Is there anything I can do the make the run faster? A wget of the page from the shell is instant (VPS in a data center)!/usr/bin/perl use strict; use warnings; use Mojo::DOM; use Mojo::UserAgent; use Data::Printer; my $ua = Mojo::UserAgent->new; my $url = 'http://www.testURL.com'; my $page = $ua->get( $url ) ->res ->dom; my $dom = Mojo::DOM->new( $page ); for my $deal ( $dom->find('p.title > a.title')->each ){ ProcessLink( $deal->attr('href'), $deal->text ); } sub ProcessLink{ warn "process link\n"; my ( $linkURL, $linkText ) = @_; print "Link: $linkURL | Title: $linkText"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simple script goes from 2s to ~2mins when run on VPS
by Discipulus (Canon) on Mar 17, 2016 at 08:46 UTC | |
|
Re: Simple script goes from 2s to ~2mins when run on VPS
by BrowserUk (Patriarch) on Mar 17, 2016 at 01:02 UTC | |
|
Re: Simple script goes from 2s to ~2mins when run on VPS (regexes)
by tye (Sage) on Mar 17, 2016 at 21:17 UTC | |
|
Re: Simple script goes from 2s to ~2mins when run on VPS
by perlfan (Parson) on Mar 17, 2016 at 00:31 UTC | |
|
Re: Simple script goes from 2s to ~2mins when run on VPS
by Anonymous Monk on Mar 16, 2016 at 21:40 UTC |