File tree Expand file tree Collapse file tree 8 files changed +17
-28
lines changed
WebApiClientCore.Benchmarks Expand file tree Collapse file tree 8 files changed +17
-28
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class Program
9
9
static void Main ( string [ ] args )
10
10
{
11
11
var benchmarkTypes = typeof ( Program ) . Assembly . GetTypes ( )
12
- . Where ( item => typeof ( IBenchmark ) . IsAssignableFrom ( item ) )
12
+ . Where ( item => typeof ( Requests . Benchmark ) . IsAssignableFrom ( item ) )
13
13
. Where ( item => item . IsAbstract == false && item . IsClass ) ;
14
14
15
15
foreach ( var item in benchmarkTypes )
Original file line number Diff line number Diff line change 3
3
using Refit ;
4
4
using System ;
5
5
using System . Net . Http ;
6
- using System . Threading . Tasks ;
7
6
8
7
namespace WebApiClientCore . Benchmarks . Requests
9
8
{
@@ -15,7 +14,7 @@ public abstract class Benchmark : IBenchmark
15
14
16
15
17
16
[ GlobalSetup ]
18
- public async Task SetupAsync ( )
17
+ public void Setup ( )
19
18
{
20
19
var services = new ServiceCollection ( ) ;
21
20
@@ -41,17 +40,6 @@ public async Task SetupAsync()
41
40
. ConfigureHttpClient ( c => c . BaseAddress = new Uri ( "http://webapiclient.com/" ) ) ;
42
41
43
42
this . ServiceProvider = services . BuildServiceProvider ( ) ;
44
-
45
- using var scope = this . ServiceProvider . CreateScope ( ) ;
46
-
47
- var core = scope . ServiceProvider . GetService < IWebApiClientCoreApi > ( ) ;
48
- var refit = scope . ServiceProvider . GetService < IRefitApi > ( ) ;
49
-
50
- await core . GetAsyc ( "id" ) ;
51
- await core . PostJsonAsync ( new Model { } ) ;
52
-
53
- await refit . GetAsyc ( "id" ) ;
54
- await refit . PostJsonAsync ( new Model { } ) ;
55
43
}
56
44
}
57
45
}
Original file line number Diff line number Diff line change @@ -38,8 +38,8 @@ public async Task<Model> HttpClient_GetAsync()
38
38
public async Task < Model > WebApiClientCore_GetAsync ( )
39
39
{
40
40
using var scope = this . ServiceProvider . CreateScope ( ) ;
41
- var banchmarkApi = scope . ServiceProvider . GetRequiredService < IWebApiClientCoreApi > ( ) ;
42
- return await banchmarkApi . GetAsyc ( id : "id" ) ;
41
+ var benchmarkApi = scope . ServiceProvider . GetRequiredService < IWebApiClientCoreApi > ( ) ;
42
+ return await benchmarkApi . GetAsync ( id : "id" ) ;
43
43
}
44
44
45
45
@@ -51,8 +51,8 @@ public async Task<Model> WebApiClientCore_GetAsync()
51
51
public async Task < Model > Refit_GetAsync ( )
52
52
{
53
53
using var scope = this . ServiceProvider . CreateScope ( ) ;
54
- var banchmarkApi = scope . ServiceProvider . GetRequiredService < IRefitApi > ( ) ;
55
- return await banchmarkApi . GetAsyc ( id : "id" ) ;
54
+ var benchmarkApi = scope . ServiceProvider . GetRequiredService < IRefitApi > ( ) ;
55
+ return await benchmarkApi . GetAsync ( id : "id" ) ;
56
56
}
57
57
}
58
58
}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ namespace WebApiClientCore.Benchmarks.Requests
6
6
public interface IRefitApi
7
7
{
8
8
[ Get ( "/benchmarks/{id}" ) ]
9
- Task < Model > GetAsyc ( string id ) ;
9
+ Task < Model > GetAsync ( string id ) ;
10
10
11
11
[ Post ( "/benchmarks" ) ]
12
12
Task < Model > PostJsonAsync ( [ Body ( BodySerializationMethod . Serialized ) ] Model model ) ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ namespace WebApiClientCore.Benchmarks.Requests
6
6
public interface IWebApiClientCoreApi
7
7
{
8
8
[ HttpGet ( "/benchmarks/{id}" ) ]
9
- Task < Model > GetAsyc ( string id ) ;
9
+ Task < Model > GetAsync ( string id ) ;
10
10
11
11
[ HttpPost ( "/benchmarks" ) ]
12
12
Task < Model > PostJsonAsync ( [ JsonContent ] Model model ) ;
Original file line number Diff line number Diff line change @@ -42,19 +42,19 @@ public async Task<Model> HttpClient_PostJsonAsync()
42
42
public async Task < Model > WebApiClientCore_PostJsonAsync ( )
43
43
{
44
44
using var scope = this . ServiceProvider . CreateScope ( ) ;
45
- var banchmarkApi = scope . ServiceProvider . GetRequiredService < IWebApiClientCoreApi > ( ) ;
45
+ var benchmarkApi = scope . ServiceProvider . GetRequiredService < IWebApiClientCoreApi > ( ) ;
46
46
var input = new Model { A = "a" } ;
47
- return await banchmarkApi . PostJsonAsync ( input ) ;
47
+ return await benchmarkApi . PostJsonAsync ( input ) ;
48
48
}
49
49
50
50
51
51
[ Benchmark ]
52
52
public async Task < Model > Refit_PostJsonAsync ( )
53
53
{
54
54
using var scope = this . ServiceProvider . CreateScope ( ) ;
55
- var banchmarkApi = scope . ServiceProvider . GetRequiredService < IRefitApi > ( ) ;
55
+ var benchmarkApi = scope . ServiceProvider . GetRequiredService < IRefitApi > ( ) ;
56
56
var input = new Model { A = "a" } ;
57
- return await banchmarkApi . PostJsonAsync ( input ) ;
57
+ return await benchmarkApi . PostJsonAsync ( input ) ;
58
58
}
59
59
}
60
60
}
Original file line number Diff line number Diff line change @@ -18,19 +18,19 @@ public class PutFormBenchmark : Benchmark
18
18
public async Task < Model > WebApiClientCore_PutFormAsync ( )
19
19
{
20
20
using var scope = this . ServiceProvider . CreateScope ( ) ;
21
- var banchmarkApi = scope . ServiceProvider . GetRequiredService < IWebApiClientCoreApi > ( ) ;
21
+ var benchmarkApi = scope . ServiceProvider . GetRequiredService < IWebApiClientCoreApi > ( ) ;
22
22
var input = new Model { A = "a" } ;
23
- return await banchmarkApi . PutFormAsync ( "id001" , input ) ;
23
+ return await benchmarkApi . PutFormAsync ( "id001" , input ) ;
24
24
}
25
25
26
26
27
27
[ Benchmark ]
28
28
public async Task < Model > Refit_PutFormAsync ( )
29
29
{
30
30
using var scope = this . ServiceProvider . CreateScope ( ) ;
31
- var banchmarkApi = scope . ServiceProvider . GetRequiredService < IRefitApi > ( ) ;
31
+ var benchmarkApi = scope . ServiceProvider . GetRequiredService < IRefitApi > ( ) ;
32
32
var input = new Model { A = "a" } ;
33
- return await banchmarkApi . PutFormAsync ( "id001" , input ) ;
33
+ return await benchmarkApi . PutFormAsync ( "id001" , input ) ;
34
34
}
35
35
}
36
36
}
Original file line number Diff line number Diff line change 16
16
17
17
<ItemGroup >
18
18
<ProjectReference Include =" ..\WebApiClientCore\WebApiClientCore.csproj" />
19
+ <ProjectReference Include =" ..\WebApiClientCore.Analyzers\WebApiClientCore.Analyzers.csproj" OutputItemType =" Analyzer" ReferenceOutputAssembly =" false" />
19
20
</ItemGroup >
20
21
21
22
</Project >
You can’t perform that action at this time.
0 commit comments