|
1 | 1 | using System.ComponentModel.Design; |
2 | 2 | using BenchmarkDotNet.Attributes; |
| 3 | +using Benchmarks.Tools; |
3 | 4 | using JsonApiDotNetCore; |
4 | 5 | using JsonApiDotNetCore.Configuration; |
5 | 6 | using JsonApiDotNetCore.Middleware; |
6 | 7 | using JsonApiDotNetCore.QueryStrings; |
7 | 8 | using JsonApiDotNetCore.QueryStrings.Internal; |
8 | 9 | using JsonApiDotNetCore.Resources; |
9 | | -using Microsoft.AspNetCore.Http; |
10 | | -using Microsoft.AspNetCore.WebUtilities; |
11 | 10 | using Microsoft.Extensions.Logging.Abstractions; |
12 | 11 |
|
13 | 12 | namespace Benchmarks.QueryString; |
@@ -71,31 +70,9 @@ public void DescendingSort() |
71 | 70 | [Benchmark] |
72 | 71 | public void ComplexQuery() |
73 | 72 | { |
74 | | - Run(100, () => |
75 | | - { |
76 | | - const string queryString = |
77 | | - "?filter[alt-attr-name]=abc,eq:abc&sort=-alt-attr-name&include=child&page[size]=1&fields[alt-resource-name]=alt-attr-name"; |
78 | | - |
79 | | - _queryStringAccessor.SetQueryString(queryString); |
80 | | - _queryStringReader.ReadAll(null); |
81 | | - }); |
82 | | - } |
83 | | - |
84 | | - private void Run(int iterations, Action action) |
85 | | - { |
86 | | - for (int index = 0; index < iterations; index++) |
87 | | - { |
88 | | - action(); |
89 | | - } |
90 | | - } |
91 | | - |
92 | | - private sealed class FakeRequestQueryStringAccessor : IRequestQueryStringAccessor |
93 | | - { |
94 | | - public IQueryCollection Query { get; private set; } = new QueryCollection(); |
| 73 | + const string queryString = "?filter[alt-attr-name]=abc,eq:abc&sort=-alt-attr-name&include=child&page[size]=1&fields[alt-resource-name]=alt-attr-name"; |
95 | 74 |
|
96 | | - public void SetQueryString(string queryString) |
97 | | - { |
98 | | - Query = new QueryCollection(QueryHelpers.ParseQuery(queryString)); |
99 | | - } |
| 75 | + _queryStringAccessor.SetQueryString(queryString); |
| 76 | + _queryStringReader.ReadAll(null); |
100 | 77 | } |
101 | 78 | } |
0 commit comments