! eof() is super slow - see test results
Blitz3D Forums/Blitz3D Programming/! eof() is super slow - see test results
| ||
| H! I was testing something with getting the a ip from my website and have this test results with eof() 23 seconds with-out eof() 1 or less seconds !!! the only thing is that you must know how many line's you need to read. (but I can use php for that) code with eof()
www=OpenTCPStream("213.211.129.194",80)
If Not www RuntimeError "Failed to connect"
WriteLine www,"GET /get_ip.php HTTP/1.1"
WriteLine www,"Host: www.zquare.nl"
WriteLine www,"User-Agent: ZquareTest"
WriteLine www,"Accept: */*"
WriteLine www,""
While Not Eof(www)
Print ReadLine(www)
Wend
CloseTCPStream www
code with-out eof()
www=OpenTCPStream("213.211.129.194",80)
If Not www RuntimeError "Failed to connect"
WriteLine www,"GET /get_ip.php HTTP/1.1"
WriteLine www,"Host: www.zquare.nl"
WriteLine www,"User-Agent: ZquareTest"
WriteLine www,"Accept: */*"
WriteLine www,""
;or for loop etc.
Print ReadLine(www)
Print ReadLine(www)
Print ReadLine(www)
Print ReadLine(www)
Print ReadLine(www)
Print ReadLine(www)
Print ReadLine(www)
Print ReadLine(www)
Print ReadLine(www)
Print ReadLine(www)
CloseTCPStream www
|
| ||
With EOF = 997ms
Start=MilliSecs()
www=OpenTCPStream("www.blitzbasic.com",80)
If Not www RuntimeError "Failed to connect"
WriteLine www,"GET http://www.blitzbasic.com HTTP/1.0"
WriteLine www,"Host: www.blitzbasic.com HTTP/1.0"
WriteLine www,"User-Agent: ZquareTest"
WriteLine www,"Accept: */*"
WriteLine www, Chr$(10)
While Not Eof(www)
Print ReadLine(www)
Wend
CloseTCPStream www
Print MilliSecs()-Start
WaitKey()
without EOF: 667ms
Start=MilliSecs()
www=OpenTCPStream("www.blitzbasic.com",80)
If Not www RuntimeError "Failed to connect"
WriteLine www,"GET http://www.blitzbasic.com HTTP/1.1"
WriteLine www,"Host: www.blitzbasic.com"
WriteLine www,"User-Agent: ZquareTest"
WriteLine www,"Accept: */*"
WriteLine www,""
;or for loop etc.
Print ReadLine(www)
Print ReadLine(www)
Print ReadLine(www)
Print ReadLine(www)
Print ReadLine(www)
Print ReadLine(www)
Print ReadLine(www)
Print ReadLine(www)
Print ReadLine(www)
Print ReadLine(www)
CloseTCPStream www
Print MilliSecs()-Start
WaitKey()
Hardly a major difference. |
| ||
| that's probably due to the way, the servers handle the time-close stuff individually, if you don't add it to the header (connection keep alive, time wait etc.) I guess you'll find some information about it in the HTTP RFC. |
| ||
| @Perturbatio If you want to test it do it right. What you did is a bad request You did : WriteLine www,"GET www.blitzbasic.com HTTP/1.1" that's wrong. ------------------ This time my code above and with timers and have this results: with-out 282 with eof 10282 @ jfk I will check that, right now. edit: You need to add this to make 10000 times faster WriteLine www,"Connection: close" |
| ||
| ok, thanks. Now is this technical instinct? ;) |
| ||
| Yeah, it's all based on TCPTimeOuts, EOF is very fast. TCP Timing out if very slow default. :) |