我可以使用RestSharp获得响应时间吗?

时间:2018-03-01 10:20:11

标签: c# restsharp

我想使用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;
    }
}

0 个答案:

没有答案