http - How can I get absolute time with java? -
this question has answer here:
i want measure how long spend when post http request server1 server2, 1 thing need consider that, server1 , server2 not in same host, , there time not consistent, plan this:
i need post parameter named starttime
before http request post server2, value is:
long starttime = system.currenttimemillis();
when server2 received request server1, variable name endtime
:
long endtime = system.currenttimemillis();
and result :
long result = endtime - starttime;
if time of server1 , server2 not consistent, result meaningless, need know how absolute time of starttime , endtime, can me ?
why aren't using ntp 2 host in sync?
it's complicate task millisecond precision evaluation of latency introduced internet communication between 2 hosts, , need use external absolute reference.
if hosts linux boxes can use ntpdate update system time. if want cool can integrate java ntp client in app (even if it'll easier sync host timing ntpdate). ntp java client can found here http://support.ntp.org/bin/view/support/javasntpclient
Comments
Post a Comment