{"action":"closed","issue":{"url":"https://api.github.com/repos/restsharp/RestSharp/issues/803","repository_url":"https://api.github.com/repos/restsharp/RestSharp","labels_url":"https://api.github.com/repos/restsharp/RestSharp/issues/803/labels{/name}","comments_url":"https://api.github.com/repos/restsharp/RestSharp/issues/803/comments","events_url":"https://api.github.com/repos/restsharp/RestSharp/issues/803/events","html_url":"https://github.com/restsharp/RestSharp/issues/803","id":127581510,"number":803,"title":"Bad Performance of restsharp, please help!","user":{"login":"phoenixjun","id":4190962,"avatar_url":"https://avatars2.githubusercontent.com/u/4190962?v=4","gravatar_id":"","url":"https://api.github.com/users/phoenixjun","html_url":"https://github.com/phoenixjun","followers_url":"https://api.github.com/users/phoenixjun/followers","following_url":"https://api.github.com/users/phoenixjun/following{/other_user}","gists_url":"https://api.github.com/users/phoenixjun/gists{/gist_id}","starred_url":"https://api.github.com/users/phoenixjun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phoenixjun/subscriptions","organizations_url":"https://api.github.com/users/phoenixjun/orgs","repos_url":"https://api.github.com/users/phoenixjun/repos","events_url":"https://api.github.com/users/phoenixjun/events{/privacy}","received_events_url":"https://api.github.com/users/phoenixjun/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-01-20T01:21:29Z","updated_at":"2017-10-25T18:42:55Z","closed_at":"2017-10-25T18:42:55Z","author_association":"NONE","body":"Hi,\n\nI find some performance issue in the restsharp client, I am sending request to some restful API using RestSharp in function PerformanceRequest2 and using normal .net request using WebRequest in PerformRequest\n\nThe average response time for PerformRequest is 75ms while the PerformRequest2 using RestSharp is 300ms. Is that some limitation of restsharp or we did something wrong the way we are using restsharp\n\n```\n    private static void PerformRequest2(string requestData)\n    {\n        var request = JsonConvert.DeserializeObject<ComplexClass>(requestData);\n        var client2 = new RestClient(\"URL\");\n        var restRequest = new RestRequest();\n        restRequest.Method = Method.PUT;\n        restRequest.AddHeader(\"Content-Type\", \"application/json\");\n        restRequest.AddHeader(\"Authorization\", string.Format(\"Bearer {0}\", token));\n\n        restRequest.AddJsonBody(request);\n\n        var restResponse2 = client2.Execute(restRequest);\n        if (restResponse2.StatusCode != HttpStatusCode.OK)\n        {\n            throw new Exception(\"error\");\n        }\n    }\n\n\n    private static void PerformRequest(string requestData)\n    {\n        var request = JsonConvert.DeserializeObject<ComplexClass>(requestData);\n        var webRequest =\n            WebRequest.Create(\"URL\");\n        webRequest.ContentType = \"application/json\";\n        webRequest.Method = \"PUT\";\n        webRequest.Headers.Add(HttpRequestHeader.Authorization, string.Format(\"Bearer {0}\", token));\n        using (var streamWriter = new StreamWriter(webRequest.GetRequestStream()))\n        {\n            streamWriter.Write(JsonConvert.SerializeObject(request));\n            streamWriter.Flush();\n        }\n        var httpResponse = (HttpWebResponse) webRequest.GetResponse();\n\n        using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))\n        {\n            var result = streamReader.ReadToEnd();\n            if (string.IsNullOrEmpty(result))\n            {\n                throw new Exception(\"error\");\n            }\n        }\n    }\n```\n"}}
{"actor":{"display_login":"alexeyzimarev"}}