我想使用 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;
}
}
Run Code Online (Sandbox Code Playgroud)