Performance

Near-native performance - since version 5.0 typed requests allocate the same as using HttpClient and System.Text.Json by hand, and several times leaner than RestSharp.

Version 5.0 had a performance pass guided by BenchmarkDotNet - requests and responses are serialized straight to and from utf-8 bytes skipping intermediate strings, the JSON DOM is only built if you use dynamic access (typed casts skip it entirely), and arrays are wrapped lazily.

4.x vs 5.0

Before and after the performance pass, 10,000 item JSON payload, in process (no network), .NET 8:

Scenario 4.x 5.0
Typed response List<User> 22.1 ms / 9.87 MB 13.5 ms / 5.10 MB
Dynamic access result[0].id 8.86 ms / 6.59 MB 5.28 ms / 5.46 MB
Typed response single object 5.98 µs / 4.59 KB 3.66 µs / 2.95 KB
POST List<User> body 5.83 ms / 3.40 MB 3.69 ms / 1.13 MB

Measured against using HttpClient and System.Text.Json by hand, POST request bodies and typed responses now allocate about the same (1.0x), down from 3.0x and 3.5x respectively.

Compared to other REST clients

A real GET request to the GitHub API deserialized to a typed model, compared to native HttpClient and other popular REST clients, .NET 8:

Client Median Allocated
HttpClient + GetFromJsonAsync 51.01 ms 11.38 KB
DalSoft.RestClient 5.0 41.38 ms 23.24 KB
RestSharp 114.0 45.45 ms 135.74 KB
Flurl.Http 4.0.2 19.64 ms 19.79 KB
Refit 15.0 39.55 ms 17.80 KB
RestClient.Net 7.2.1 * 51.07 ms 15.27 KB

Time over a real network is dominated by latency so every client lands within noise of native HttpClient - don’t read the time column as a ranking, the differences (including where a client appears faster than native HttpClient) are statistical noise. The allocations column is what shows the overhead each library adds per request. DalSoft.RestClient stays close to native and the lightweight clients while giving you a full dynamic API, and allocates about 6x less than RestSharp.

* RestClient.Net 7 doesn’t deserialize for you - you supply your own System.Text.Json delegate, so its numbers exclude the library-side JSON handling every other row includes.

Run the benchmarks yourself

The benchmarks live in the DalSoft.RestClient repo - dotnet run -c Release in the DalSoft.RestClient.Benchmarks project.

The real world benchmark makes around 50 requests - GitHub allows 60 unauthenticated requests an hour, set the GITHUB_TOKEN environment variable to raise the limit.

Updated: