Jesse Smith has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use CGI ':standard'; $video = param('video'); use LWP::Simple qw(!head); $url = get ("http://www.domain.org/facebookvideos/$video/"); $url =~ s*<meta property="og:description" content="Text of the talk: +<a href='http://domain.org/general-conference/([^&]+)/([^&]+)/([^&]+) + '>http://domain.org/general-confere...</a> ">*<meta property="og:des +cription" content="Text of the talk: http://domain.org/general-confer +ence/$1/$2/$3" />*g; #$url =~ s*tion\" content\=\"*tion\" content\=\"Want more\?\? http://w +ww.domain2.org/ *g; $url =~ s*og:url" content="http://www.domain2.org/videos/*og:url" cont +ent="http://www.domain2.org/facebook/*g; #$url =~ s*Want more\?\? http://www.domain2.org/ Text*Text*g; #facebookexternalhit or Mozilla if ($ENV{'HTTP_USER_AGENT'} =~ /facebookexternalhit/) { print "Content-Type: text/html\n\n"; print <<EOM; $url EOM } else { print "Location: http://www.youtube.com/watch?v=$video\n\n"; EOM }
generates top - 23:51:16 up 23:18, 1 user, load average: 69.62, 36.45, 15.11 Tasks: 134 total, 45 running, 86 sleeping, 0 stopped, 3 zombie Cpu(s): 99.7%us, 0.3%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 786432k total, 786432k used, 0k free, 0k buffers Swap: 4264k total, 4264k used, 0k free, 0k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1512 site100 19 0 55248 11m 1876 R 3.3 1.5 0:01.39 facebook.cgi 1943 site100 19 0 55248 11m 1876 R 3.3 1.5 0:01.09 facebook.cgi 4018 site100 19 0 55248 11m 1876 R 3.3 1.5 0:01.09 facebook.cgi 4024 site100 19 0 55280 11m 1876 R 3.3 1.5 0:02.78 facebook.cgi 4029 site100 19 0 55248 11m 1876 R 3.3 1.5 0:02.81 facebook.cgi 4034 site100 19 0 55280 11m 1876 R 3.3 1.5 0:02.79 facebook.cgi 4044 site100 19 0 55248 11m 1876 R 3.3 1.5 0:01.09 facebook.cgi 4057 site100 19 0 55280 11m 1876 R 3.3 1.5 0:01.04 facebook.cgi 4060 site100 19 0 55280 11m 1876 R 3.3 1.5 0:01.11 facebook.cgiHow do you make the script do what it should do in a second or two instead of it spending five minutes killing the server???
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Script needs major optimizing.
by Corion (Patriarch) on Dec 30, 2011 at 08:28 UTC | |
|
Re: Script needs major optimizing.
by i5513 (Pilgrim) on Dec 30, 2011 at 12:23 UTC | |
by Jesse Smith (Acolyte) on Dec 31, 2011 at 08:21 UTC | |
|
Re: Script needs major optimizing.
by Anonymous Monk on Dec 30, 2011 at 10:46 UTC |