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
99 static void Main ( string [ ] args )
1010 {
1111 var benchmarkTypes = typeof ( Program ) . Assembly . GetTypes ( )
12- . Where ( item => typeof ( IBenchmark ) . IsAssignableFrom ( item ) )
12+ . Where ( item => typeof ( Requests . Benchmark ) . IsAssignableFrom ( item ) )
1313 . Where ( item => item . IsAbstract == false && item . IsClass ) ;
1414
1515 foreach ( var item in benchmarkTypes )
Original file line number Diff line number Diff line change 33using Refit ;
44using System ;
55using System . Net . Http ;
6- using System . Threading . Tasks ;
76
87namespace WebApiClientCore . Benchmarks . Requests
98{
@@ -15,7 +14,7 @@ public abstract class Benchmark : IBenchmark
1514
1615
1716 [ GlobalSetup ]
18- public async Task SetupAsync ( )
17+ public void Setup ( )
1918 {
2019 var services = new ServiceCollection ( ) ;
2120
@@ -41,17 +40,6 @@ public async Task SetupAsync()
4140 . ConfigureHttpClient ( c => c . BaseAddress = new Uri ( "http://webapiclient.com/" ) ) ;
4241
4342 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 { } ) ;
5543 }
5644 }
5745}
Original file line number Diff line number Diff line change @@ -38,8 +38,8 @@ public async Task<Model> HttpClient_GetAsync()
3838 public async Task < Model > WebApiClientCore_GetAsync ( )
3939 {
4040 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" ) ;
4343 }
4444
4545
@@ -51,8 +51,8 @@ public async Task<Model> WebApiClientCore_GetAsync()
5151 public async Task < Model > Refit_GetAsync ( )
5252 {
5353 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" ) ;
5656 }
5757 }
5858}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ namespace WebApiClientCore.Benchmarks.Requests
66 public interface IRefitApi
77 {
88 [ Get ( "/benchmarks/{id}" ) ]
9- Task < Model > GetAsyc ( string id ) ;
9+ Task < Model > GetAsync ( string id ) ;
1010
1111 [ Post ( "/benchmarks" ) ]
1212 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
66 public interface IWebApiClientCoreApi
77 {
88 [ HttpGet ( "/benchmarks/{id}" ) ]
9- Task < Model > GetAsyc ( string id ) ;
9+ Task < Model > GetAsync ( string id ) ;
1010
1111 [ HttpPost ( "/benchmarks" ) ]
1212 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()
4242 public async Task < Model > WebApiClientCore_PostJsonAsync ( )
4343 {
4444 using var scope = this . ServiceProvider . CreateScope ( ) ;
45- var banchmarkApi = scope . ServiceProvider . GetRequiredService < IWebApiClientCoreApi > ( ) ;
45+ var benchmarkApi = scope . ServiceProvider . GetRequiredService < IWebApiClientCoreApi > ( ) ;
4646 var input = new Model { A = "a" } ;
47- return await banchmarkApi . PostJsonAsync ( input ) ;
47+ return await benchmarkApi . PostJsonAsync ( input ) ;
4848 }
4949
5050
5151 [ Benchmark ]
5252 public async Task < Model > Refit_PostJsonAsync ( )
5353 {
5454 using var scope = this . ServiceProvider . CreateScope ( ) ;
55- var banchmarkApi = scope . ServiceProvider . GetRequiredService < IRefitApi > ( ) ;
55+ var benchmarkApi = scope . ServiceProvider . GetRequiredService < IRefitApi > ( ) ;
5656 var input = new Model { A = "a" } ;
57- return await banchmarkApi . PostJsonAsync ( input ) ;
57+ return await benchmarkApi . PostJsonAsync ( input ) ;
5858 }
5959 }
6060}
Original file line number Diff line number Diff line change @@ -18,19 +18,19 @@ public class PutFormBenchmark : Benchmark
1818 public async Task < Model > WebApiClientCore_PutFormAsync ( )
1919 {
2020 using var scope = this . ServiceProvider . CreateScope ( ) ;
21- var banchmarkApi = scope . ServiceProvider . GetRequiredService < IWebApiClientCoreApi > ( ) ;
21+ var benchmarkApi = scope . ServiceProvider . GetRequiredService < IWebApiClientCoreApi > ( ) ;
2222 var input = new Model { A = "a" } ;
23- return await banchmarkApi . PutFormAsync ( "id001" , input ) ;
23+ return await benchmarkApi . PutFormAsync ( "id001" , input ) ;
2424 }
2525
2626
2727 [ Benchmark ]
2828 public async Task < Model > Refit_PutFormAsync ( )
2929 {
3030 using var scope = this . ServiceProvider . CreateScope ( ) ;
31- var banchmarkApi = scope . ServiceProvider . GetRequiredService < IRefitApi > ( ) ;
31+ var benchmarkApi = scope . ServiceProvider . GetRequiredService < IRefitApi > ( ) ;
3232 var input = new Model { A = "a" } ;
33- return await banchmarkApi . PutFormAsync ( "id001" , input ) ;
33+ return await benchmarkApi . PutFormAsync ( "id001" , input ) ;
3434 }
3535 }
3636}
Original file line number Diff line number Diff line change 1616
1717 <ItemGroup >
1818 <ProjectReference Include =" ..\WebApiClientCore\WebApiClientCore.csproj" />
19+ <ProjectReference Include =" ..\WebApiClientCore.Analyzers\WebApiClientCore.Analyzers.csproj" OutputItemType =" Analyzer" ReferenceOutputAssembly =" false" />
1920 </ItemGroup >
2021
2122</Project >
You can’t perform that action at this time.
0 commit comments