Skip to content

Commit 3e5610d

Browse files
Merge pull request #24 from martincostello/Update-Benchmarks
Update benchmarks
2 parents 2a014ac + cfcbcd9 commit 3e5610d

File tree

2 files changed

+45
-33
lines changed

2 files changed

+45
-33
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,24 +139,24 @@ Further examples of using the library can be found by following the links below:
139139

140140
### Benchmarks
141141

142-
Generated with the [Benchmarks project](https://github.com/justeat/httpclient-interception/blob/master/tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs "JustEat.HttpClientInterception benchmark code") using [BenchmarkDotNet](https://github.com/dotnet/BenchmarkDotNet "BenchmarkDotNet on GitHub.com") using commit [a442f1d](https://github.com/justeat/httpclient-interception/commit/a442f1d72701bedd5920be23561c1e12a05fb43f "Benchmark commit") on 23/09/2017.
142+
Generated with the [Benchmarks project](https://github.com/justeat/httpclient-interception/blob/master/tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs "JustEat.HttpClientInterception benchmark code") using [BenchmarkDotNet](https://github.com/dotnet/BenchmarkDotNet "BenchmarkDotNet on GitHub.com") using commit [c09c38b](https://github.com/justeat/httpclient-interception/commit/c09c38bad3ed5db6cfffdbaebeac33c2d286764f "Benchmark commit") on 11/03/2018.
143143

144144
``` ini
145-
BenchmarkDotNet=v0.10.9, OS=Windows 10 Redstone 2 (10.0.15063)
146-
Processor=Intel Core i7-6500U CPU 2.50GHz (Skylake), ProcessorCount=4
147-
Frequency=2531249 Hz, Resolution=395.0619 ns, Timer=TSC
148-
.NET Core SDK=2.0.0
149-
[Host] : .NET Core 2.0.0 (Framework 4.6.00001.0), 64bit RyuJIT
150-
DefaultJob : .NET Core 2.0.0 (Framework 4.6.00001.0), 64bit RyuJIT
145+
BenchmarkDotNet=v0.10.12, OS=Windows 10 Redstone 3 [1709, Fall Creators Update] (10.0.16299.248)
146+
Intel Core i7-6700HQ CPU 2.60GHz (Skylake), 1 CPU, 8 logical cores and 4 physical cores
147+
Frequency=2531248 Hz, Resolution=395.0620 ns, Timer=TSC
148+
.NET Core SDK=2.1.4
149+
[Host] : .NET Core 2.0.5 (Framework 4.6.26020.03), 64bit RyuJIT
150+
DefaultJob : .NET Core 2.0.5 (Framework 4.6.26020.03), 64bit RyuJIT
151151
```
152152

153153
| Method | Mean | Error | StdDev |
154154
|---------- |----------:|----------:|----------:|
155-
| [`GetBytes`](https://github.com/justeat/httpclient-interception/blob/a442f1d72701bedd5920be23561c1e12a05fb43f/tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs#L61-L65 "Benchmark using a byte array") | 3.604 μs | 0.0639 μs | 0.0567 μs |
156-
| [`GetHtml`](https://github.com/justeat/httpclient-interception/blob/a442f1d72701bedd5920be23561c1e12a05fb43f/tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs#L67-L71 "Benchmark using HTML") | 4.674 μs | 0.0881 μs | 0.0781 μs |
157-
| [`GetJson`](https://github.com/justeat/httpclient-interception/blob/a442f1d72701bedd5920be23561c1e12a05fb43f/tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs#L73-L78 "Benchmark using JSON") | 12.295 μs | 0.2015 μs | 0.1683 μs |
158-
| [`GetStream`](https://github.com/justeat/httpclient-interception/blob/a442f1d72701bedd5920be23561c1e12a05fb43f/tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs#L80-L86 "Benchmark using a stream") | 99.040 μs | 1.9611 μs | 3.0531 μs |
159-
| [`Refit`](https://github.com/justeat/httpclient-interception/blob/a442f1d72701bedd5920be23561c1e12a05fb43f/tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs#L88-L92 "Benchmark using Refit") | 33.651 μs | 0.5165 μs | 0.4831 μs |
155+
| [`GetBytes`](https://github.com/justeat/httpclient-interception/blob/c09c38bad3ed5db6cfffdbaebeac33c2d286764f/tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs#L73-L77 "Benchmark using a byte array") | 8.310 μs | 0.0916 μs | 0.0857 μs |
156+
| [`GetHtml`](https://github.com/justeat/httpclient-interception/blob/c09c38bad3ed5db6cfffdbaebeac33c2d286764f/tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs#L79-L83 "Benchmark using HTML") | 8.476 μs | 0.0462 μs | 0.0361 μs |
157+
| [`GetJson`](https://github.com/justeat/httpclient-interception/blob/c09c38bad3ed5db6cfffdbaebeac33c2d286764f/tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs#L85-L90 "Benchmark using JSON") | 17.519 μs | 0.2440 μs | 0.2282 μs |
158+
| [`GetStream`](https://github.com/justeat/httpclient-interception/blob/c09c38bad3ed5db6cfffdbaebeac33c2d286764f/tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs#L92-L98 "Benchmark using a stream") | 72.442 μs | 0.9177 μs | 0.8135 μs |
159+
| [`Refit`](https://github.com/justeat/httpclient-interception/blob/c09c38bad3ed5db6cfffdbaebeac33c2d286764f/tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs#L100-L104 "Benchmark using Refit") | 46.388 μs | 0.4742 μs | 0.4436 μs |
160160

161161
## Feedback
162162

tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,53 @@ public class InterceptionBenchmarks
1818

1919
public InterceptionBenchmarks()
2020
{
21-
var builderForBytes = new HttpRequestInterceptionBuilder()
22-
.ForHttps()
23-
.ForHost("files.domain.com")
24-
.ForPath("setup.exe")
25-
.WithMediaType("application/octet-stream")
26-
.WithContent(() => new byte[] { 0, 1, 2, 3, 4 });
21+
_options = new HttpClientInterceptorOptions()
22+
{
23+
ThrowOnMissingRegistration = true,
24+
};
2725

28-
var builderForHtml = new HttpRequestInterceptionBuilder()
26+
var builder = new HttpRequestInterceptionBuilder();
27+
28+
builder
29+
.Requests()
2930
.ForHttp()
3031
.ForHost("www.google.co.uk")
3132
.ForPath("search")
3233
.ForQuery("q=Just+Eat")
34+
.Responds()
3335
.WithMediaType("text/html")
34-
.WithContent(@"<!DOCTYPE html><html dir=""ltr"" lang=""en""><head><title>Just Eat</title></head></html>");
36+
.WithContent(@"<!DOCTYPE html><html dir=""ltr"" lang=""en""><head><title>Just Eat</title></head></html>")
37+
.RegisterWith(_options);
3538

36-
var builderForJson = new HttpRequestInterceptionBuilder()
39+
builder
40+
.Requests()
3741
.ForHttps()
38-
.ForHost("api.github.com")
39-
.ForPath("orgs/justeat")
40-
.WithMediaType("application/json")
41-
.WithJsonContent(new { id = 1516790, login = "justeat", url = "https://api.github.com/orgs/justeat" });
42+
.ForPort(443)
43+
.ForHost("files.domain.com")
44+
.ForPath("setup.exe")
45+
.ForQuery(string.Empty)
46+
.Responds()
47+
.WithMediaType("application/octet-stream")
48+
.WithContent(() => new byte[] { 0, 1, 2, 3, 4 })
49+
.RegisterWith(_options);
4250

43-
var builderForStream = new HttpRequestInterceptionBuilder()
51+
builder
52+
.Requests()
4453
.ForHttps()
4554
.ForHost("api.github.com")
4655
.ForPath("orgs/justeat")
47-
.ForQuery("page=1")
56+
.ForQuery(string.Empty)
57+
.Responds()
4858
.WithMediaType("application/json")
49-
.WithContentStream(() => File.OpenRead("organization.json"));
59+
.WithJsonContent(new { id = 1516790, login = "justeat", url = "https://api.github.com/orgs/justeat" })
60+
.RegisterWith(_options);
5061

51-
_options = new HttpClientInterceptorOptions()
52-
.Register(builderForBytes)
53-
.Register(builderForHtml)
54-
.Register(builderForJson)
55-
.Register(builderForStream);
62+
builder
63+
.Requests()
64+
.ForQuery("page=1")
65+
.Responds()
66+
.WithContentStream(() => File.OpenRead("organization.json"))
67+
.RegisterWith(_options);
5668

5769
_client = _options.CreateHttpClient();
5870
_service = RestService.For<IGitHub>(_options.CreateHttpClient("https://api.github.com"));

0 commit comments

Comments
 (0)