這是一個非常酷的測試 - 你的技術聽起來像是一個很好的解決方案。
您是否在某處保存日期&次答案?難道是時差(0.04 &分別爲0.02秒)是由於記錄這些日期需要多長時間?也就是說,如果你保存到數據庫中,例如,由於類似帶索引的大表等,插入/更新可能需要一些時間才能完成。
編輯 我嘗試以下方法使用WCF服務器&客戶端在同一臺機器上運行的模擬 - 以排除WCF本身可能是出於某種原因很慢。這似乎並非如此,我只能建議嘗試,如果事件日誌可能會導致延誤找出的情況下,或者如果確有您的網絡設置一些奇怪的滯後
我的服務器代碼:
public interface IServiceWCF
{
[OperationContract]
DateTime TestConnectionSpeed(DateTime messageSentFromClientTime, out DateTime messageReceivedAtServerTime, out int millisecondsBetweenClientSentAndServerReceived);
}
public class ServiceWCF : IServiceWCF
{
public DateTime TestConnectionSpeed(DateTime messageSentFromClientTime, out DateTime messageReceivedAtServerTime, out int millisecondsBetweenClientSentAndServerReceived)
{
messageReceivedAtServerTime = DateTime.Now;
TimeSpan span = messageReceivedAtServerTime - messageSentFromClientTime;
millisecondsBetweenClientSentAndServerReceived = (int)span.TotalMilliseconds;
return DateTime.Now;
}
}
我的客戶端代碼
int millisecondsBetweenClientSentAndServerReceived;
DateTime clientSent = DateTime.Now;
DateTime serverReceived;
DateTime serverSent = wcfService.TestConnectionSpeed(clientSent, out serverReceived, out millisecondsBetweenClientSentAndServerReceived);
DateTime responseReceived = DateTime.Now;
TimeSpan span = responseReceived - serverSent;
int millisecondsBetweenServerSentAndClientReceived = (int)span.TotalMilliseconds;
Console.WriteLine("Message sent from client at {0} - server received {1} milliseconds later at {2} - server response sent at {3} - was received at client {4} milliseconds later at {5}",
clientSent,
millisecondsBetweenClientSentAndServerReceived,
serverReceived,
serverSent,
millisecondsBetweenServerSentAndClientReceived,
responseReceived);
而答案大多是非常快的 - 1毫秒 - 看樣輸出:
Message sent from client at 3/24/2017 3:56:22 PM - server received 1 milliseconds later at 3/24/2017 3:56:22 PM - server response sent at 3/24/2017 3:56:22 PM - was received at client 1 milliseconds later at 3/24/2017 3:56:22 PM
不意味着作爲垃圾埠我會建議你的迴應是一個後續評論,而不是一個問題。但是,我很欣賞這種迴應,我很高興在這裏繼續與你交談。跟進你的問題。雙方都將錄製到兩個單獨的本地SQL服務器中。但是記錄的時間來自c#代碼,而不是SQL的時間戳記。是的,至少在服務器端,您所考慮的所有這些延遲都納入了兩個客戶端時間戳。僅分析兩個客戶端時間戳就顯示0.04個交易/秒。 – Steve
注意到後續評論 - 但很抱歉,我的評分太低,不能評論你的問題;) – Thys
大聲笑。我不知道評級必須超過這麼多評論。似乎顛倒。你應該可以評論但不能回答。答案意味着一些評論沒有的專業知識。 – Steve