-
I compared three JSON serialization and deserialization frameworks, and after testing, I found that the performance of ServiceStack was not ideal. Code: var faker = new Faker<User>()
.CustomInstantiator(f => new User(
Guid.NewGuid(),
f.Name.FirstName(),
f.Name.LastName(),
f.Name.FullName(),
f.Internet.UserName(f.Name.FirstName(), f.Name.LastName()),
f.Internet.Email(f.Name.FirstName(), f.Name.LastName())
));
Stopwatch stopwatch;
string text;
var users = faker.Generate(10000);
stopwatch = Stopwatch.StartNew();
text = Newtonsoft.Json.JsonConvert.SerializeObject(users);
stopwatch.Stop();
Console.WriteLine($"JSON.NET Serialized {users.Count} users in {stopwatch.ElapsedMilliseconds}ms");
stopwatch = Stopwatch.StartNew();
text = JsonSerializer.SerializeToString(users);
stopwatch.Stop();
Console.WriteLine($"ServiceStack Serialized {users.Count} users in {stopwatch.ElapsedMilliseconds}ms");
stopwatch = Stopwatch.StartNew();
text = System.Text.Json.JsonSerializer.Serialize(users);
stopwatch.Stop();
Console.WriteLine($"Microsoft Serialized {users.Count} users in {stopwatch.ElapsedMilliseconds}ms"); Results: JSON.NET Serialized 10000 users in 117ms Can the performance of ServiceStack in JSON processing be improved? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 17 replies
-
Now, Microsoft's JSON serializer stands out in terms of performance. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
FYI from v8.1 ServiceStack now uses System.Text.Json by default in its Endpoint Routing APIs for Serializing/Deserializing its JSON APIs. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your timely notification! |
Beta Was this translation helpful? Give feedback.
FYI from v8.1 ServiceStack now uses System.Text.Json by default in its Endpoint Routing APIs for Serializing/Deserializing its JSON APIs.