Programming-Language-Benchmarks icon indicating copy to clipboard operation
Programming-Language-Benchmarks copied to clipboard

Some improvements - C#

Open hugobritobh opened this issue 3 years ago • 0 comments

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):

Link - Source Generator NET 6

hugobritobh avatar Aug 12 '22 20:08 hugobritobh