c# - Setup time Metrics for Webservice Call -


i calling webservice send json data post method. here code that:

string sample_url = "mywebservice/createsample; httpwebrequest request = (httpwebrequest)webrequest.create(sample_url); request.method = "post"; request.contenttype = "application/x-www-form-urlencoded"; request.cookiecontainer = new cookiecontainer(); cookiecollection cookcol = new cookiecollection(); cookcol.add(cookie);  string body= json data byte[] postbytes = encoding.utf8.getbytes(body); request.contentlength = postbytes.length; stream poststream = request.getrequeststream(); poststream.write(postbytes, 0, postbytes.length);  poststream.close();  webresponse response = request.getresponse(); string satus = ((httpwebresponse)response).statusdescription; poststream = response.getresponsestream(); streamreader reader = new streamreader(poststream); 

i need timestamp around webservice request , response service seems quite slow. how put countdown timer around this? response.

you can use stopwatch class:

stopwatch sw = new stopwatch();  sw.start();  // code measure here  sw.stop();  // print sw.elapsed 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -