How to check the HTTP web server respond speed

Alex Tweedly alex at tweedly.net
Tue Jan 3 05:27:30 EST 2006


alex wu wrote:

>Hello,
>
>I want to compare the speed of webservers.  I try to
>use the following function.  However the respond time
>(Server_Speed) of almost all servers I test is zero. 
>I don't believe that the response speed of all
>webservers are so fast - zero.  There must be some
>problem with the way I calculate it.  Please help.
>
>  
>
Alex,

your problem is that "open socket" doesn't wait until the connection is 
established. From the docs:

> When a connection is made, the open socket command creates a new 
> socket that can be used to communicate with the other system. The 
> handler continues executing while the connection is being established. 
> If you use the write to socket command while the connection is 
> opening, the data is buffered and is sent to the host as soon as the 
> connection is made.

You should be able to write a single byte to the socket - write to 
socket does pause until the write is completed so this should give you 
valid timings.

("valid timings" - this will give you approximately valid timings for 
connection establishment - there's a lot more than that involved in the 
overall speed of a web server, so I'd be very careful how much I read 
into these results ...)

>function haveIPconnect
>  put fld "domain" into theHostName
>  if colon is not in theHostName then
>    put colon & "80|test" after theHostName
>  end if
>  
>  ## Record the start time
>  put the long seconds into startTime
>
>  open socket theHostName
>  
>
>  if theHostName is among the lines of the openSockets
>then
>
>    ## Calculate the response time
>    put the long seconds - startTime into Server_Speed
>
>    close socket theHostName
>    return true
>  else
>    beep
>    answer warning "The site may be down"
>    return false
>  end if
>end haveIPconnect
>
>  
>

-- 
Alex Tweedly       http://www.tweedly.net



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.9/217 - Release Date: 30/12/2005




More information about the use-livecode mailing list