Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change IPerformanceService to return HttpResponseMessage #1893

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading