Is there a way to make this faster?

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

Is there a way to make this faster?

Post by gerry.odea »

Or does it seem ok?


<a name=SEARCH>
<$Ip=$REMOTE_ADDR>
<strfmt "%U" $HTTP_USER_AGENT>
<$rexchars="[[\\=+*?{.>!\^$$]">
<sandr $rexchars "\\\1" $ret>
<$useragent=$ret>
<strfmt "%U" $q>
<sandr "[\?\#\{\}\+\\]" "\\\1" $ret>
<sandr "xyzzy" $ret $searchurl>
<$fetchthis = $ret>
<sandr "ayazzy" $start $fetchthis>
<sandr "aaabbb" $resultsdisplay $ret>
<sandr "aaaccz" $adsdisplay $ret>
<sandr "ppyazzy" $page $ret>
<sandr "ipyxxy" $Ip $ret>
<sandr "uayzzy" $useragent $ret>
<sandr "spyzzy" $safe $ret>
<sandr "pbyzzy" $channelid $ret>
<$liveurls = $ret>
<$acturls = >
<$actimports = >
<$actimports1 = >
<$actimports2 = >
<$acturls = $acturls $liveurls>
<$actimports = $actimports $imports>
<$actimports1 = $actimports1 $imports1>
<$actimports2 = $actimports2 $imports2>
<urlcp timeout 6>
<fetch PARALLEL $acturls $actimports $actimports1 $actimports2><$html=$ret><flush></fetch>
<$try=1>

<if $html = ""><$try=2>
<strfmt "%U" $q>
<sandr "[\?\#\{\}\+\\]" "\\\1" $ret>
<sandr "xyzzy" $ret $searchurl1>
<$fetchthis = $ret>
<sandr "ayazzy" $start $fetchthis>
<sandr "aaabbb" $resultsdisplay $ret>
<sandr "aaaccz" $adsdisplay $ret>
<sandr "ppyazzy" $page $ret>
<sandr "ipyxxy" $Ip $ret>
<sandr "uayzzy" $useragent $ret>
<sandr "spyzzy" $safe $ret>
<sandr "pbyzzy" $channelid $ret>
<$liveurls = $ret>
<$acturls = >
<$actimports = >
<$actimports1 = >
<$actimports2 = >
<$acturls = $acturls $liveurls>
<$actimports = $actimports $imports>
<$actimports1 = $actimports1 $imports1>
<$actimports2 = $actimports2 $imports2>
<urlcp timeout 6>
<fetch PARALLEL $acturls $actimports $actimports1 $actimports2><$html=$ret><flush></fetch>
</if>

<if $html = ""><$try=3>
<strfmt "%U" $q>
<sandr "[\?\#\{\}\+\\]" "\\\1" $ret>
<sandr "xyzzy" $ret $searchurl2>
<$fetchthis = $ret>
<sandr "ayazzy" $start $fetchthis>
<sandr "aaabbb" $resultsdisplay $ret>
<sandr "aaaccz" $adsdisplay $ret>
<sandr "ppyazzy" $page $ret>
<sandr "ipyxxy" $Ip $ret>
<sandr "uayzzy" $useragent $ret>
<sandr "spyzzy" $safe $ret>
<sandr "pbyzzy" $channelid $ret>
<$liveurls = $ret>
<$acturls = >
<$actimports = >
<$actimports1 = >
<$actimports2 = >
<$acturls = $acturls $liveurls>
<$actimports = $actimports $imports>
<$actimports1 = $actimports1 $imports1>
<$actimports2 = $actimports2 $imports2>
<urlcp timeout 6>
<fetch PARALLEL $acturls $actimports $actimports1 $actimports2><$html=$ret><flush></fetch>
</if>

<if $html = ""><$try=4>
<strfmt "%U" $q>
<sandr "[\?\#\{\}\+\\]" "\\\1" $ret>
<sandr "xyzzy" $ret $searchurl3>
<$fetchthis = $ret>
<sandr "ayazzy" $start $fetchthis>
<sandr "aaabbb" $resultsdisplay $ret>
<sandr "aaaccz" $adsdisplay $ret>
<sandr "ppyazzy" $page $ret>
<sandr "ipyxxy" $Ip $ret>
<sandr "uayzzy" $useragent $ret>
<sandr "spyzzy" $safe $ret>
<sandr "pbyzzy" $channelid $ret>
<$liveurls = $ret>
<$acturls = >
<$actimports = >
<$actimports1 = >
<$actimports2 = >
<$acturls = $acturls $liveurls>
<$actimports = $actimports $imports>
<$actimports1 = $actimports1 $imports1>
<$actimports2 = $actimports2 $imports2>
<urlcp timeout 6>
<fetch PARALLEL $acturls $actimports $actimports1 $actimports2><$html=$ret><flush></fetch>
</if>

<if $html = ""><$try=5>
<strfmt "%U" $q>
<sandr "[\?\#\{\}\+\\]" "\\\1" $ret>
<sandr "xyzzy" $ret $searchurl4>
<$fetchthis = $ret>
<sandr "ayazzy" $start $fetchthis>
<sandr "aaabbb" $resultsdisplay $ret>
<sandr "aaaccz" $adsdisplay $ret>
<sandr "ppyazzy" $page $ret>
<sandr "ipyxxy" $Ip $ret>
<sandr "uayzzy" $useragent $ret>
<sandr "spyzzy" $safe $ret>
<sandr "pbyzzy" $channelid $ret>
<$liveurls = $ret>
<$acturls = >
<$actimports = >
<$actimports1 = >
<$actimports2 = >
<$acturls = $acturls $liveurls>
<$actimports = $actimports $imports>
<$actimports1 = $actimports1 $imports1>
<$actimports2 = $actimports2 $imports2>
<urlcp timeout 6>
<fetch PARALLEL $acturls $actimports $actimports1 $actimports2><$html=$ret><flush></fetch>
</if>

<if $html = ""><$try=6>
<strfmt "%U" $q>
<sandr "[\?\#\{\}\+\\]" "\\\1" $ret>
<sandr "xyzzy" $ret $searchurl5>
<$fetchthis = $ret>
<sandr "ayazzy" $start $fetchthis>
<sandr "aaabbb" $resultsdisplay $ret>
<sandr "aaaccz" $adsdisplay $ret>
<sandr "ppyazzy" $page $ret>
<sandr "ipyxxy" $Ip $ret>
<sandr "uayzzy" $useragent $ret>
<sandr "spyzzy" $safe $ret>
<sandr "pbyzzy" $channelid $ret>
<$liveurls = $ret>
<$acturls = >
<$actimports = >
<$actimports1 = >
<$actimports2 = >
<$acturls = $acturls $liveurls>
<$actimports = $actimports $imports>
<$actimports1 = $actimports1 $imports1>
<$actimports2 = $actimports2 $imports2>
<urlcp timeout 6>
<fetch PARALLEL $acturls $actimports $actimports1 $actimports2><$html=$ret><flush></fetch>
</if>

<a name=GOOGLE>
<$searchurl = "http://www.google.com/search?">
<$searchurl1 = "http://www.l.google.com/search?">
<$searchurl2 = "http://64.233.169.104/search?">
<$searchurl3 = "http://64.233.169.147/search?">
<$searchurl4 = "http://64.233.169.99/search?">
<$searchurl5 = "http://64.233.169.103/search?">
<$imports='
recdelim >><GSP
multiple
field SN varchar(10) />>\RSN\P\=\x22=[^\x22]+ ""
field EN varchar(10) />>\REN\P\=\x22=[^\x22]+ ""
field Counted varchar(20) />><M>\P=!</M>+ ""
field Pell varchar(20) />>\Rq\P\=\x22=[^\x22]+ ""
'>
<$imports1='
recdelim >><AD
multiple
field ADShowURL varchar(35) />>\Rvisible_url\P\=\x22=[^\x22]+ ""
field ADLink varchar(80) /!visible_=>>\Rurl\P\=\x22=[^\x22]+
field ADType varchar(10) />>\Rtype\P\=\x22=[^\x22]+ ""
field ADTitle varchar(40) />><LINE1>\P=!</LINE1>+ ""
field ADAbstract varchar(80) />><LINE2>\P=!</LINE2>+ ""
field ADAbstract2 varchar(40) />><LINE3>\P=!</LINE3>+ ""
'>
<$imports2='
recdelim >><R\x20N
multiple
field Link varchar(40) />><U>\P=!</U>+ ""
field ShowURL varchar(40) />><U>\P=!</U>+ ""
field Title varchar(80) />><T>\P=!</T>+ ""
field Title2 varchar(80) />><DT>\P=!</DT>+ ""
field Abstract varchar(80) />><S>\P=!</S>+ ""
field Abstract2 varchar(80) />><DS>\P=!</DS>+ ""
field Cache varchar(40) />>\RCID\P\=\x22=[^\x22]+ ""
'>
</a>
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

Is there a way to make this faster?

Post by mark »

Hard to follow the replicated code. You might want to look into using arrays and loops or at least function calls to make the code maintainable.

Doing the sandrs in one call would be slightly faster.
<$search="ayazzy" "aaabbb" "aaaccz" ...>
<$replace=$start $resultsdisplay $adsdisplay ...>
<sandr $search $replace $fetchthis>
<$liveurls=$ret>
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

Is there a way to make this faster?

Post by mark »

Also, by assigning $html inside the fetch loop you're only going to get the html of the last page. And the flush inside the fetch loop is pointless.
gerry.odea
Posts: 98
Joined: Fri Sep 19, 2008 9:33 am

Is there a way to make this faster?

Post by gerry.odea »

I was trying to put in something to make sure that if I don't get a result set back that it went out again and tried again. It's helpful if the DNS is not found so it tries a different url. There is only one page to get.

And thank you Mark for the other suggestions, I am using them, but for using this

<$search="ayazzy" "aaabbb" "aaaccz" ...>
<$replace=$start $resultsdisplay $adsdisplay ...>
<sandr $search $replace $fetchthis>

every variables has to be assigned a value, because it will end up skipping it and messing the rest of the variable up. As I came to find out.

What is the purpase of the <flush> I'm still not sure even after reading Thunderstone's literature about it?
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

Is there a way to make this faster?

Post by mark »

In that case you want to <break> out of the fetch parallel after the first result.

Initialize empty vars as <$var=""> instead of <$var=> to avoid the missing item syndrome.

All of vortex's output to the user goes through a buffer so output is in large chunks for efficiency instead of sending every string as you print them. <flush> forces the buffer to be output even if it's not full yet. It's sometimes desired for real-time or interactive usage.
Post Reply