小编dum*_*ing的帖子

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

c# restsharp

5
推荐指数
0
解决办法
2133
查看次数

标签 统计

c# ×1

restsharp ×1