Can this be optimized to be faster?

Post Reply
gerry.odea
Posts: 98
Joined: Fri Sep 19, 2008 9:33 am

Can this be optimized to be faster?

Post by gerry.odea »

What could I do to make this quicker? Also is there a way to easily put a check in the code that if $html="" for it to resend the fetch until it gets something but not more than 3 tries?

<strfmt "%U" $q>
<sandr "[\?\#\{\}\+\\]" "\\\1" $ret>
<sandr "xyzzy" $ret $searchurl>
<sandr "ayazzy" $start $ret>
<sandr "aaabbb" $resultsdisplay $ret>
<sandr "aaaccz" $adsdisplay $ret>
<sandr "ppyazzy" $page $ret>
<sandr "ipyxxy" $Ip $ret>
<sandr "uayzzy" $useragent $ret>
<sandr "pyzzy" $safe $ret>
<sandr "crcrcr" $pro $ret>
<sandr "hwxqhw" $lang $ret>
<if $pro neq ""><sandr "hrhrhr" $country $ret></if>
<$liveurls = $ret>
<$acturls = >
<$actimports = >
<$actimports1 = >
<$actimports2 = >
<$acturls = $acturls $liveurls>
<$actimports = $actimports $imports>
<$actimports1 = $actimports1 $imports1>
<$actimports2 = $actimports2 $imports2>
<urlcp timeout 30>
<fmtcp query "%mbH" $q>
<fetch PARALLEL $acturls $actimports $actimports1 $actimports2>
<$html=$ret>
<flush></fetch><flush>
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

Can this be optimized to be faster?

Post by mark »

A bunch of unrelated sandrs so no way to reduce them.
Their time usage is probably negligible.

No way to tell <fetch> to automatically retry. You would have to do that yourself.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

Can this be optimized to be faster?

Post by mark »

You don't give any context, but it looks like you may be doing this in some kind of loop. If possible it would a little more efficient to do the sandrs outside of the loop so it could operate on each array once instead doing each member as you loop over them.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

Can this be optimized to be faster?

Post by mark »

You could also make the sandr slightly more efficient by giving it all of the search and replaces in one call so the variables don't have to be passed around so much:

<$s="xyzzy" "ayazzy" "aaabbb" ... "hwxqhw">
<$r=$ret $start $resultsdisplay ... $lang >
<if $pro neq ""><$s=$s "hrhrhr"><$r=$r $country></if>
<sandr $s $r $searchurl>
<$liveurls = $ret>
Post Reply