我想使用RestSharp计算时间响应,但实际上我正在使用秒表功能来执行我的目标。是否有其他方法使用restSharp函数来获取时间响应?或者这个是最佳选择?
public class LoadingTimes
{
public Stopwatch Stopwatch = new Stopwatch();
public List<double> GetResponsesTimesForSelectedPage(PageInformation pageInformation)
{
var responsesTimesList = new List<double>();
var client = new RestClient(pageInformation.Url);
var request = new RestRequest("/City/berlijn/", Method.GET);
for (int actualExecution = 1; actualExecution <= pageInformation.ExecutionsCount; actualExecution++)
{
Stopwatch.Start();
client.Execute(request);
Stopwatch.Stop();
responsesTimesList.Add(Stopwatch.Elapsed.TotalMilliseconds);
Stopwatch.Reset();
}
return responsesTimesList;
}
}