KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: An approach to checking latency between 4D Server and 4D Client
PRODUCT: 4D | VERSION: 17 | PLATFORM: Mac & Win
Published On: July 10, 2019
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Here is a simple method that can be used to check the latency between the 4D Server and 4D Client.

C_LONGINT($beginMS;$endMS;$a;$min;$max;$i;$end)
ARRAY LONGINT($al_latency;0)
C_TIME($trash)
C_TEXT($crlf;$tab)

$crlf:=Char(Carriage return)+Char(Line feed)
$tab:=Char(Tab)

$end:=100
For ($i;0;$end)
   $beginMS:=Milliseconds
   $trash:=Current time(*)
   $endMS:=Milliseconds
   APPEND TO ARRAY($al_latency;$endMS-$beginMS)
End for

$init:=$al_latency{1}
DELETE FROM ARRAY($al_latency;1;1)

$a:=Average($al_latency)
$min:=Min($al_latency)
$max:=Max($al_latency)

$msg:=""
$msg:=$msg+"tests ran: "+$tab+$tab+String($end)+$crlf
$msg:=$msg+"min latency: "+$tab+$tab+String($min)+"ms"+$crlf
$msg:=$msg+"max latency: "+$tab+$tab+String($max)+"ms"+$crlf
$msg:=$msg+"average latency: "+$tab+String($a)+"ms"+$crlf
$msg:=$msg+"init latency: "+$tab+$tab+String($init)+"ms (first connection)"+$crlf

ALERT($msg)



Here is an example of the output observed when 4D Client and 4D Server are ran on the same physical machine:



Here is an example of the output observed when running 4D Client on a Wifi network local to the 4D Server: