私は問題を抱えていて、気が狂ってしまいます。私のアプリでは、ローカル スタンプの値、サーバーへの要求の待ち時間、サーバー スタンプ、およびアプリへの応答の待ち時間を取得する必要があります。
取得できる唯一の値は、ローカル スタンプ、サーバー スタンプ、および完全なサイクル (要求 + 応答) の時間です。では、リクエストのレイテンシとレスポンスのレイテンシを取得する方法について説明します。
php でリクエストを実行している場合は、次の行に沿って何かを使用できます。
<?php
// start a timer
$start_time = microtime(true);
// do some network stuff
// example is read google.com
$buffer = file_get_contents('http://www.google.com');
// echo the current time minus the start time
echo number_format(microtime(true) - $start_time, 5) . ' seconds';
long sendtime,latncyTime;
HttpPost httppost = new HttpPost("http://your-url.com");
List<BasicNameValuePair> nameValuePairs = new ArrayList<BasicNameValuePair>(
2);
nameValuePairs.add(new BasicNameValuePair("username",
"ARUN"));
nameValuePairs.add(new BasicNameValuePair("password",
"****"));
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
sendtime=System.currentTimeMillis();
HttpResponse response = httpclient.execute(httppost);
if (response.getStatusLine().getStatusCode() == 200) {
latncyTime=System..currentTimeMillis()-sendtime;
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}