Programming-Language-Benchmarks
Programming-Language-Benchmarks copied to clipboard
Some improvements - C#
Very nice comparisons. Here are some improvements that can be made in C#
-
Some cases use Span<T> or Memory<T> Link - Span, Memory
-
Some cases use ValueTask instead of Task Link - ValueTask
-
For C# use Source Generator for Json (example below) and if possible bytes instead of string.
[JsonSerializable(typeof(Person))]
internal partial class MyJsonContext : JsonSerializerContext
{
}
Person person = new() { FirstName = "Jane", LastName = "Doe" };
byte[] utf8Json = JsonSerializer.SerializeToUtf8Bytes(person, MyJsonContext.Default.Person);
person = JsonSerializer.Deserialize(utf8Json, MyJsonContext.Default.Person):