Skip to content

Commit

Permalink
feat: change IPerformanceService to return HttpResponseMessage (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyMakkison authored Oct 26, 2024
1 parent 7ea950a commit 6de1dbb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions Refit.Benchmarks/IPerformanceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
public interface IPerformanceService
{
[Get("/users")]
public Task<string> ConstantRoute();
public Task<HttpResponseMessage> ConstantRoute();

[Get("/users/{id}")]
public Task<string> DynamicRoute(int id);
public Task<HttpResponseMessage> DynamicRoute(int id);

[Get("/users/{id}/{user}/{status}")]
public Task<string> ComplexDynamicRoute(int id, string user, string status);
public Task<HttpResponseMessage> ComplexDynamicRoute(int id, string user, string status);

[Get("/users/{request.someProperty}")]
public Task<string> ObjectRequest(PathBoundObject request);
public Task<HttpResponseMessage> ObjectRequest(PathBoundObject request);

[Post("/users/{id}/{request.someProperty}")]
[Headers("User-Agent: Awesome Octocat App", "X-Emoji: :smile_cat:")]
public Task<string> ComplexRequest(int id, PathBoundObject request, [Query(CollectionFormat.Multi)]int[] queries);
public Task<HttpResponseMessage> ComplexRequest(int id, PathBoundObject request, [Query(CollectionFormat.Multi)]int[] queries);
}

public class PathBoundObject
Expand Down
10 changes: 5 additions & 5 deletions Refit.Benchmarks/PerformanceBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ public Task SetupAsync()
}

[Benchmark]
public async Task<string> ConstantRouteAsync() => await service.ConstantRoute();
public async Task<HttpResponseMessage> ConstantRouteAsync() => await service.ConstantRoute();

[Benchmark]
public async Task<string> DynamicRouteAsync() => await service.DynamicRoute(101);
public async Task<HttpResponseMessage> DynamicRouteAsync() => await service.DynamicRoute(101);

[Benchmark]
public async Task<string> ComplexDynamicRouteAsync() => await service.ComplexDynamicRoute(101, "tom", "yCxv");
public async Task<HttpResponseMessage> ComplexDynamicRouteAsync() => await service.ComplexDynamicRoute(101, "tom", "yCxv");

[Benchmark]
public async Task<string> ObjectRequestAsync() => await service.ObjectRequest(new PathBoundObject(){SomeProperty = "myProperty", SomeQuery = "myQuery"});
public async Task<HttpResponseMessage> ObjectRequestAsync() => await service.ObjectRequest(new PathBoundObject(){SomeProperty = "myProperty", SomeQuery = "myQuery"});

[Benchmark]
public async Task<string> ComplexRequestAsync() => await service.ComplexRequest(101, new PathBoundObject(){SomeProperty = "myProperty", SomeQuery = "myQuery"}, [1,2,3,4,5,6]);
public async Task<HttpResponseMessage> ComplexRequestAsync() => await service.ComplexRequest(101, new PathBoundObject(){SomeProperty = "myProperty", SomeQuery = "myQuery"}, [1,2,3,4,5,6]);
}
8 changes: 4 additions & 4 deletions Refit.Benchmarks/StartupBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ public void Setup()
public IPerformanceService CreateService() => RestService.For<IPerformanceService>(Host, settings);

[Benchmark]
public async Task<string> FirstCallConstantRouteAsync() => await initialisedService.ConstantRoute();
public async Task<HttpResponseMessage> FirstCallConstantRouteAsync() => await initialisedService.ConstantRoute();

[Benchmark]
public async Task<string> ConstantRouteAsync()
public async Task<HttpResponseMessage> ConstantRouteAsync()
{
var service = RestService.For<IPerformanceService>(Host, settings);
return await service.ConstantRoute();
}

[Benchmark]
public async Task<string> FirstCallComplexRequestAsync() => await initialisedService.ObjectRequest(new PathBoundObject(){SomeProperty = "myProperty", SomeQuery = "myQuery"});
public async Task<HttpResponseMessage> FirstCallComplexRequestAsync() => await initialisedService.ObjectRequest(new PathBoundObject(){SomeProperty = "myProperty", SomeQuery = "myQuery"});

[Benchmark]
public async Task<string> ComplexRequestAsync()
public async Task<HttpResponseMessage> ComplexRequestAsync()
{
var service = RestService.For<IPerformanceService>(Host, settings);
return await service.ObjectRequest(new PathBoundObject(){SomeProperty = "myProperty", SomeQuery = "myQuery"});
Expand Down

0 comments on commit 6de1dbb

Please sign in to comment.