-
Notifications
You must be signed in to change notification settings - Fork 450
feat(benchmarks): 添加 RestSharp 基准测试支持 #285
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
base: master
Are you sure you want to change the base?
Conversation
添加 RestSharp 作为新的 HTTP 客户端基准测试工具 在多个请求类型中实现 RestSharp 的基准测试方法 配置 RestSharp 客户端服务并添加相关包装类
WalkthroughAdds RestSharp to the benchmarks project, registers two RestSharp wrapper clients in GlobalSetup, and introduces RestSharp-based benchmark methods for GET/POST/PUT with JSON, XML, and form payloads mirroring existing benchmark patterns. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code graph analysis (1)WebApiClientCore.Benchmarks/Requests/HttpPutFormBenchmark.cs (1)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
WebApiClientCore.Benchmarks/Requests/HttpGetBenchmark.cs (1)
26-33: Consider using explicit HTTP method for clarity.The benchmark uses
ExecuteAsyncwithout explicitly specifying the HTTP method. WhileRestRequestdefaults to GET, consider usingGetAsync()or explicitly setting the method for better readability and consistency with other RestSharp benchmarks.Apply this diff to use the explicit GET method:
- var request = new RestRequest($"/benchmarks/id001"); - await client.ExecuteAsync(request); + var request = new RestRequest($"/benchmarks/id001"); + await client.GetAsync(request);WebApiClientCore.Benchmarks/Requests/HttpPostXmlBenchmark.cs (1)
4-6: Remove unused imports.The
System.Net.Http(line 4) andSystem(line 6) namespaces don't appear to be used in this file.Apply this diff to remove the unused imports:
using BenchmarkDotNet.Attributes; using Microsoft.Extensions.DependencyInjection; using RestSharp; -using System.Net.Http; using System.Threading.Tasks; -using System;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
WebApiClientCore.Benchmarks/Requests/Benchmark.cs(3 hunks)WebApiClientCore.Benchmarks/Requests/HttpGetBenchmark.cs(2 hunks)WebApiClientCore.Benchmarks/Requests/HttpGetJsonBenchmark.cs(2 hunks)WebApiClientCore.Benchmarks/Requests/HttpPostJsonBenchmark.cs(2 hunks)WebApiClientCore.Benchmarks/Requests/HttpPostXmlBenchmark.cs(2 hunks)WebApiClientCore.Benchmarks/Requests/HttpPutFormBenchmark.cs(2 hunks)WebApiClientCore.Benchmarks/WebApiClientCore.Benchmarks.csproj(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (5)
WebApiClientCore.Benchmarks/Requests/HttpGetBenchmark.cs (4)
WebApiClientCore.Benchmarks/Requests/HttpGetJsonBenchmark.cs (3)
Benchmark(10-16)Benchmark(18-24)Benchmark(26-33)WebApiClientCore.Benchmarks/Requests/HttpPostJsonBenchmark.cs (3)
Benchmark(10-16)Benchmark(19-25)Benchmark(27-35)WebApiClientCore.Benchmarks/Requests/HttpPutFormBenchmark.cs (3)
Benchmark(10-16)Benchmark(18-24)Benchmark(26-40)WebApiClientCore.Benchmarks/Requests/Benchmark.cs (4)
Task(99-108)Task(114-123)RestSharpJsonClient(127-132)RestSharpJsonClient(129-131)
WebApiClientCore.Benchmarks/Requests/HttpPostXmlBenchmark.cs (3)
WebApiClientCore.Benchmarks/Requests/HttpGetBenchmark.cs (3)
Benchmark(10-16)Benchmark(18-24)Benchmark(26-33)WebApiClientCore.Benchmarks/Requests/HttpPostJsonBenchmark.cs (3)
Benchmark(10-16)Benchmark(19-25)Benchmark(27-35)WebApiClientCore.Benchmarks/Requests/Benchmark.cs (4)
Task(99-108)Task(114-123)RestSharpXmlClient(135-140)RestSharpXmlClient(137-139)
WebApiClientCore.Benchmarks/Requests/HttpPostJsonBenchmark.cs (1)
WebApiClientCore.Benchmarks/Requests/Benchmark.cs (2)
RestSharpJsonClient(127-132)RestSharpJsonClient(129-131)
WebApiClientCore.Benchmarks/Requests/HttpPutFormBenchmark.cs (1)
WebApiClientCore.Benchmarks/Requests/HttpGetBenchmark.cs (3)
Benchmark(10-16)Benchmark(18-24)Benchmark(26-33)
WebApiClientCore.Benchmarks/Requests/HttpGetJsonBenchmark.cs (2)
WebApiClientCore.Benchmarks/Requests/HttpGetBenchmark.cs (3)
Benchmark(10-16)Benchmark(18-24)Benchmark(26-33)WebApiClientCore.Benchmarks/User.cs (2)
User(8-49)User(43-48)
🔇 Additional comments (6)
WebApiClientCore.Benchmarks/Requests/HttpPostJsonBenchmark.cs (1)
27-35: LGTM!The RestSharp POST JSON benchmark implementation is correct and follows the established pattern. The use of
AddJsonBodyandPostAsync<User>appropriately mirrors the existing Refit and WebApiClientCore benchmarks.WebApiClientCore.Benchmarks/Requests/HttpPostXmlBenchmark.cs (1)
28-36: LGTM!The RestSharp POST XML benchmark correctly uses
AddXmlBodyandPostAsync<User>, maintaining consistency with the other benchmark implementations.WebApiClientCore.Benchmarks/Requests/HttpGetJsonBenchmark.cs (1)
26-33: LGTM!The RestSharp GET JSON benchmark is well-implemented using
GetAsync<User>, which properly deserializes the response and maintains consistency with the existing Refit and WebApiClientCore patterns.WebApiClientCore.Benchmarks/Requests/Benchmark.cs (3)
61-83: LGTM!The RestSharp client configuration properly integrates with the existing HttpClientFactory pattern. The setup correctly:
- Registers named HttpClients with appropriate response handlers
- Uses transient lifetime for RestSharp clients
- Leverages IHttpClientFactory for proper HttpClient management
126-140: LGTM!The RestSharp wrapper classes are appropriately simple, serving as thin adapters that pass the managed HttpClient to RestClient's base constructor. This design allows RestSharp to participate in the benchmark while respecting the HttpClientFactory pattern.
92-93: LGTM!The warmup calls for RestSharp clients follow the existing pattern for Refit and WebApiClientCore clients, ensuring all clients are initialized before benchmarking begins.
添加 RestSharp 作为新的 HTTP 客户端基准测试工具
在多个请求类型中实现 RestSharp 的基准测试方法
配置 RestSharp 客户端服务并添加相关包装类
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.