Skip to content

Commit

Permalink
Add example returning HttpWebResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Mar 6, 2016
1 parent 110147a commit 7207a65
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Funq;
using NUnit.Framework;
using System.Collections.Generic;
using System.Net;
using ServiceStack.Text;

namespace ServiceStack.WebHost.Endpoints.Tests.Issues
Expand Down Expand Up @@ -95,5 +96,31 @@ public void Run_GET_url_in_loop()
elapsedTicks[i + 1] - elapsedTicks[i], i);
}
}

[Test]
public void Run_GET_url_HttpWebResponse_in_loop()
{
var client = new JsonServiceClient(Config.ListeningOn);

client.Get(new LeakRequest { Name = "warmup" });

var sw = Stopwatch.StartNew();
var elapsedTicks = new List<double> { sw.ElapsedMilliseconds };

for (int i = 0; i < 10001; i++)
{
using (HttpWebResponse response = client.Get("/leak/request" + i))
{
response.Close();
}
elapsedTicks.Add(sw.ElapsedTicks);
}

for (int i = 0; i < 10001; i += 1000)
{
"Elapsed Time: {0} ticks for Request at: #{1}".Print(
elapsedTicks[i + 1] - elapsedTicks[i], i);
}
}
}
}

0 comments on commit 7207a65

Please sign in to comment.